<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">{-
(c) The GRASP/AQUA Project, Glasgow University, 1992-1998

\section{GHC.Core.Opt.SetLevels}

                ***************************
                        Overview
                ***************************

1. We attach binding levels to Core bindings, in preparation for floating
   outwards (@FloatOut@).

2. We also let-ify many expressions (notably case scrutinees), so they
   will have a fighting chance of being floated sensible.

3. Note [Need for cloning during float-out]
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   We clone the binders of any floatable let-binding, so that when it is
   floated out it will be unique. Example
      (let x=2 in x) + (let x=3 in x)
   we must clone before floating so we get
      let x1=2 in
      let x2=3 in
      x1+x2

   NOTE: this can't be done using the uniqAway idea, because the variable
         must be unique in the whole program, not just its current scope,
         because two variables in different scopes may float out to the
         same top level place

   NOTE: Very tiresomely, we must apply this substitution to
         the rules stored inside a variable too.

   We do *not* clone top-level bindings, because some of them must not change,
   but we *do* clone bindings that are heading for the top level

4. Note [Binder-swap during float-out]
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In the expression
        case x of wild { p -&gt; ...wild... }
   we substitute x for wild in the RHS of the case alternatives:
        case x of wild { p -&gt; ...x... }
   This means that a sub-expression involving x is not &quot;trapped&quot; inside the RHS.
   And it's not inconvenient because we already have a substitution.

  Note that this is EXACTLY BACKWARDS from the what the simplifier does.
  The simplifier tries to get rid of occurrences of x, in favour of wild,
  in the hope that there will only be one remaining occurrence of x, namely
  the scrutinee of the case, and we can inline it.

  This can only work if @wild@ is an unrestricted binder. Indeed, even with the
  extended typing rule (in the linter) for case expressions, if
       case x of wild # 1 { p -&gt; e}
  is well-typed, then
       case x of wild # 1 { p -&gt; e[wild\x] }
  is only well-typed if @e[wild\x] = e@ (that is, if @wild@ is not used in @e@
  at all). In which case, it is, of course, pointless to do the substitution
  anyway. So for a linear binder (and really anything which isn't unrestricted),
  doing this substitution would either produce ill-typed terms or be the
  identity.
-}</span><span>
</span><span id="line-62"></span><span>
</span><span id="line-63"></span><span class="hs-pragma">{-# LANGUAGE CPP, MultiWayIf, PatternSynonyms #-}</span><span>
</span><span id="line-64"></span><span>
</span><span id="line-65"></span><span class="hs-pragma">{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}</span><span>
</span><span id="line-66"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Core.Opt.SetLevels</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-67"></span><span>        </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#setLevels"><span class="hs-identifier">setLevels</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-68"></span><span>
</span><span id="line-69"></span><span>        </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier">Level</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelType"><span class="hs-identifier">LevelType</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#tOP_LEVEL"><span class="hs-identifier">tOP_LEVEL</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#isJoinCeilLvl"><span class="hs-identifier">isJoinCeilLvl</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#asJoinCeilLvl"><span class="hs-identifier">asJoinCeilLvl</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-70"></span><span>        </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelledBind"><span class="hs-identifier">LevelledBind</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelledExpr"><span class="hs-identifier">LevelledExpr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelledBndr"><span class="hs-identifier">LevelledBndr</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-71"></span><span>        </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#FloatSpec"><span class="hs-identifier">FloatSpec</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#floatSpecLevel"><span class="hs-identifier">floatSpecLevel</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-72"></span><span>
</span><span id="line-73"></span><span>        </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#incMinorLvl"><span class="hs-identifier">incMinorLvl</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#ltMajLvl"><span class="hs-identifier">ltMajLvl</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#ltLvl"><span class="hs-identifier">ltLvl</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#isTopLvl"><span class="hs-identifier">isTopLvl</span></a></span><span>
</span><span id="line-74"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#include &quot;HsVersions.h&quot;
</span><span>
</span><span id="line-78"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-79"></span><span>
</span><span id="line-80"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.html"><span class="hs-identifier">GHC.Core</span></a></span><span>
</span><span id="line-81"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Monad.html"><span class="hs-identifier">GHC.Core.Opt.Monad</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Monad.html#FloatOutSwitches"><span class="hs-identifier">FloatOutSwitches</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-82"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html"><span class="hs-identifier">GHC.Core.Utils</span></a></span><span>   </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html#exprType"><span class="hs-identifier">exprType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html#exprIsHNF"><span class="hs-identifier">exprIsHNF</span></a></span><span>
</span><span id="line-83"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html#exprOkForSpeculation"><span class="hs-identifier">exprOkForSpeculation</span></a></span><span>
</span><span id="line-84"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html#exprIsTopLevelBindable"><span class="hs-identifier">exprIsTopLevelBindable</span></a></span><span>
</span><span id="line-85"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html#isExprLevPoly"><span class="hs-identifier">isExprLevPoly</span></a></span><span>
</span><span id="line-86"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html#collectMakeStaticArgs"><span class="hs-identifier">collectMakeStaticArgs</span></a></span><span>
</span><span id="line-87"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html#mkLamTypes"><span class="hs-identifier">mkLamTypes</span></a></span><span>
</span><span id="line-88"></span><span>                        </span><span class="hs-special">)</span><span>
</span><span id="line-89"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html"><span class="hs-identifier">GHC.Core.Opt.Arity</span></a></span><span>   </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#exprBotStrictness_maybe"><span class="hs-identifier">exprBotStrictness_maybe</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-90"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.FVs.html"><span class="hs-identifier">GHC.Core.FVs</span></a></span><span>     </span><span class="hs-comment">-- all of it</span><span>
</span><span id="line-91"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html"><span class="hs-identifier">GHC.Core.Subst</span></a></span><span>
</span><span id="line-92"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Make.html"><span class="hs-identifier">GHC.Core.Make</span></a></span><span>    </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Make.html#sortQuantVars"><span class="hs-identifier">sortQuantVars</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-93"></span><span>
</span><span id="line-94"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.html"><span class="hs-identifier">GHC.Types.Id</span></a></span><span>
</span><span id="line-95"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.Info.html"><span class="hs-identifier">GHC.Types.Id.Info</span></a></span><span>
</span><span id="line-96"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.html"><span class="hs-identifier">GHC.Types.Var</span></a></span><span>
</span><span id="line-97"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html"><span class="hs-identifier">GHC.Types.Var.Set</span></a></span><span>
</span><span id="line-98"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Set.html"><span class="hs-identifier">GHC.Types.Unique.Set</span></a></span><span>   </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Set.html#nonDetStrictFoldUniqSet"><span class="hs-identifier">nonDetStrictFoldUniqSet</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-99"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.DSet.html"><span class="hs-identifier">GHC.Types.Unique.DSet</span></a></span><span>  </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Unique.DSet.html#getUniqDSet"><span class="hs-identifier">getUniqDSet</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-100"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html"><span class="hs-identifier">GHC.Types.Var.Env</span></a></span><span>
</span><span id="line-101"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Literal.html"><span class="hs-identifier">GHC.Types.Literal</span></a></span><span>      </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Literal.html#litIsTrivial"><span class="hs-identifier">litIsTrivial</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-102"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Demand.html"><span class="hs-identifier">GHC.Types.Demand</span></a></span><span>       </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Demand.html#StrictSig"><span class="hs-identifier">StrictSig</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Demand.html#Demand"><span class="hs-identifier">Demand</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Demand.html#isStrictDmd"><span class="hs-identifier">isStrictDmd</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Demand.html#splitStrictSig"><span class="hs-identifier">splitStrictSig</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Demand.html#prependArgsStrictSig"><span class="hs-identifier">prependArgsStrictSig</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-103"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Cpr.html"><span class="hs-identifier">GHC.Types.Cpr</span></a></span><span>          </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Cpr.html#mkCprSig"><span class="hs-identifier">mkCprSig</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Cpr.html#botCpr"><span class="hs-identifier">botCpr</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-104"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.html"><span class="hs-identifier">GHC.Types.Name</span></a></span><span>         </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#getOccName"><span class="hs-identifier">getOccName</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#mkSystemVarName"><span class="hs-identifier">mkSystemVarName</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-105"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.Occurrence.html"><span class="hs-identifier">GHC.Types.Name.Occurrence</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Name.Occurrence.html#occNameString"><span class="hs-identifier">occNameString</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-106"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.html"><span class="hs-identifier">GHC.Types.Unique</span></a></span><span>       </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Unique.html#hasKey"><span class="hs-identifier">hasKey</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-107"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Type.html"><span class="hs-identifier">GHC.Core.Type</span></a></span><span>    </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier">Type</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Type.html#splitTyConApp_maybe"><span class="hs-identifier">splitTyConApp_maybe</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfType"><span class="hs-identifier">tyCoVarsOfType</span></a></span><span>
</span><span id="line-108"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Type.html#mightBeUnliftedType"><span class="hs-identifier">mightBeUnliftedType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.FVs.html#closeOverKindsDSet"><span class="hs-identifier">closeOverKindsDSet</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-109"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Multiplicity.html"><span class="hs-identifier">GHC.Core.Multiplicity</span></a></span><span>     </span><span class="hs-special">(</span><span> </span><span class="hs-keyword">pattern</span><span> </span><span class="annot"><a href="GHC.Core.Type.html#Many"><span class="hs-identifier">Many</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-110"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html"><span class="hs-identifier">GHC.Types.Basic</span></a></span><span>  </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#Arity"><span class="hs-identifier">Arity</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#RecFlag"><span class="hs-identifier">RecFlag</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#isRec"><span class="hs-identifier">isRec</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-111"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html"><span class="hs-identifier">GHC.Core.DataCon</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html#dataConOrigResTy"><span class="hs-identifier">dataConOrigResTy</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-112"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Types.html"><span class="hs-identifier">GHC.Builtin.Types</span></a></span><span>
</span><span id="line-113"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Names.html"><span class="hs-identifier">GHC.Builtin.Names</span></a></span><span>      </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Builtin.Names.html#runRWKey"><span class="hs-identifier">runRWKey</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-114"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Supply.html"><span class="hs-identifier">GHC.Types.Unique.Supply</span></a></span><span>
</span><span id="line-115"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html"><span class="hs-identifier">GHC.Utils.Misc</span></a></span><span>
</span><span id="line-116"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span>
</span><span id="line-117"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.FastString.html"><span class="hs-identifier">GHC.Data.FastString</span></a></span><span>
</span><span id="line-118"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.DFM.html"><span class="hs-identifier">GHC.Types.Unique.DFM</span></a></span><span>
</span><span id="line-119"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html"><span class="hs-identifier">GHC.Utils.FV</span></a></span><span>
</span><span id="line-120"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Maybe.html#"><span class="hs-identifier">Data.Maybe</span></a></span><span>
</span><span id="line-121"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html"><span class="hs-identifier">GHC.Utils.Monad</span></a></span><span>  </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html#mapAccumLM"><span class="hs-identifier">mapAccumLM</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-122"></span><span>
</span><span id="line-123"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
\subsection{Level numbers}
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-130"></span><span>
</span><span id="line-131"></span><span class="hs-keyword">type</span><span> </span><span id="LevelledExpr"><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelledExpr"><span class="hs-identifier hs-var">LevelledExpr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Core.html#TaggedExpr"><span class="hs-identifier hs-type">TaggedExpr</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#FloatSpec"><span class="hs-identifier hs-type">FloatSpec</span></a></span><span>
</span><span id="line-132"></span><span class="hs-keyword">type</span><span> </span><span id="LevelledBind"><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelledBind"><span class="hs-identifier hs-var">LevelledBind</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Core.html#TaggedBind"><span class="hs-identifier hs-type">TaggedBind</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#FloatSpec"><span class="hs-identifier hs-type">FloatSpec</span></a></span><span>
</span><span id="line-133"></span><span class="hs-keyword">type</span><span> </span><span id="LevelledBndr"><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelledBndr"><span class="hs-identifier hs-var">LevelledBndr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Core.html#TaggedBndr"><span class="hs-identifier hs-type">TaggedBndr</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#FloatSpec"><span class="hs-identifier hs-type">FloatSpec</span></a></span><span>
</span><span id="line-134"></span><span>
</span><span id="line-135"></span><span class="hs-keyword">data</span><span> </span><span id="Level"><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-var">Level</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="Level"><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-var">Level</span></a></span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>  </span><span class="hs-comment">-- Level number of enclosing lambdas</span><span>
</span><span id="line-136"></span><span>                   </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>  </span><span class="hs-comment">-- Number of big-lambda and/or case expressions and/or</span><span>
</span><span id="line-137"></span><span>                        </span><span class="hs-comment">-- context boundaries between</span><span>
</span><span id="line-138"></span><span>                        </span><span class="hs-comment">-- here and the nearest enclosing lambda</span><span>
</span><span id="line-139"></span><span>                   </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelType"><span class="hs-identifier hs-type">LevelType</span></a></span><span> </span><span class="hs-comment">-- Binder or join ceiling?</span><span>
</span><span id="line-140"></span><span class="hs-keyword">data</span><span> </span><span id="LevelType"><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelType"><span class="hs-identifier hs-var">LevelType</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="BndrLvl"><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#BndrLvl"><span class="hs-identifier hs-var">BndrLvl</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span id="JoinCeilLvl"><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#JoinCeilLvl"><span class="hs-identifier hs-var">JoinCeilLvl</span></a></span></span><span> </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680962936"><span id="local-6989586621680962938"><span class="annot"><span class="annottext">LevelType -&gt; LevelType -&gt; Bool
(LevelType -&gt; LevelType -&gt; Bool)
-&gt; (LevelType -&gt; LevelType -&gt; Bool) -&gt; Eq LevelType
forall a. (a -&gt; a -&gt; Bool) -&gt; (a -&gt; a -&gt; Bool) -&gt; Eq a
/= :: LevelType -&gt; LevelType -&gt; Bool
$c/= :: LevelType -&gt; LevelType -&gt; Bool
== :: LevelType -&gt; LevelType -&gt; Bool
$c== :: LevelType -&gt; LevelType -&gt; Bool
</span><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Eq</span></span></span></span><span class="hs-special">)</span><span>
</span><span id="line-141"></span><span>
</span><span id="line-142"></span><span class="hs-keyword">data</span><span> </span><span id="FloatSpec"><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#FloatSpec"><span class="hs-identifier hs-var">FloatSpec</span></a></span></span><span>
</span><span id="line-143"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="FloatMe"><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#FloatMe"><span class="hs-identifier hs-var">FloatMe</span></a></span></span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span>       </span><span class="hs-comment">-- Float to just inside the binding</span><span>
</span><span id="line-144"></span><span>                        </span><span class="hs-comment">--    tagged with this level</span><span>
</span><span id="line-145"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="StayPut"><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#StayPut"><span class="hs-identifier hs-var">StayPut</span></a></span></span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span>       </span><span class="hs-comment">-- Stay where it is; binding is</span><span>
</span><span id="line-146"></span><span>                        </span><span class="hs-comment">--     tagged with this level</span><span>
</span><span id="line-147"></span><span>
</span><span id="line-148"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#floatSpecLevel"><span class="hs-identifier hs-type">floatSpecLevel</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#FloatSpec"><span class="hs-identifier hs-type">FloatSpec</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span>
</span><span id="line-149"></span><span id="floatSpecLevel"><span class="annot"><span class="annottext">floatSpecLevel :: FloatSpec -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#floatSpecLevel"><span class="hs-identifier hs-var hs-var">floatSpecLevel</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#FloatMe"><span class="hs-identifier hs-type">FloatMe</span></a></span><span> </span><span id="local-6989586621680962932"><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962932"><span class="hs-identifier hs-var">l</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962932"><span class="hs-identifier hs-var">l</span></a></span><span>
</span><span id="line-150"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#floatSpecLevel"><span class="hs-identifier hs-var">floatSpecLevel</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#StayPut"><span class="hs-identifier hs-type">StayPut</span></a></span><span> </span><span id="local-6989586621680962931"><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962931"><span class="hs-identifier hs-var">l</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962931"><span class="hs-identifier hs-var">l</span></a></span><span>
</span><span id="line-151"></span><span>
</span><span id="line-152"></span><span class="hs-comment">{-
The {\em level number} on a (type-)lambda-bound variable is the
nesting depth of the (type-)lambda which binds it.  The outermost lambda
has level 1, so (Level 0 0) means that the variable is bound outside any lambda.

On an expression, it's the maximum level number of its free
(type-)variables.  On a let(rec)-bound variable, it's the level of its
RHS.  On a case-bound variable, it's the number of enclosing lambdas.

Top-level variables: level~0.  Those bound on the RHS of a top-level
definition but ``before'' a lambda; e.g., the \tr{x} in (levels shown
as ``subscripts'')...
\begin{verbatim}
a_0 = let  b_? = ...  in
           x_1 = ... b ... in ...
\end{verbatim}

The main function @lvlExpr@ carries a ``context level'' (@le_ctxt_lvl@).
That's meant to be the level number of the enclosing binder in the
final (floated) program.  If the level number of a sub-expression is
less than that of the context, then it might be worth let-binding the
sub-expression so that it will indeed float.

If you can float to level @Level 0 0@ worth doing so because then your
allocation becomes static instead of dynamic.  We always start with
context @Level 0 0@.


Note [FloatOut inside INLINE]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@InlineCtxt@ very similar to @Level 0 0@, but is used for one purpose:
to say &quot;don't float anything out of here&quot;.  That's exactly what we
want for the body of an INLINE, where we don't want to float anything
out at all.  See notes with lvlMFE below.

But, check this out:

-- At one time I tried the effect of not floating anything out of an InlineMe,
-- but it sometimes works badly.  For example, consider PrelArr.done.  It
-- has the form         __inline (\d. e)
-- where e doesn't mention d.  If we float this to
--      __inline (let x = e in \d. x)
-- things are bad.  The inliner doesn't even inline it because it doesn't look
-- like a head-normal form.  So it seems a lesser evil to let things float.
-- In GHC.Core.Opt.SetLevels we do set the context to (Level 0 0) when we get to an InlineMe
-- which discourages floating out.

So the conclusion is: don't do any floating at all inside an InlineMe.
(In the above example, don't float the {x=e} out of the \d.)

One particular case is that of workers: we don't want to float the
call to the worker outside the wrapper, otherwise the worker might get
inlined into the floated expression, and an importing module won't see
the worker at all.

Note [Join ceiling]
~~~~~~~~~~~~~~~~~~~
Join points can't float very far; too far, and they can't remain join points
So, suppose we have:

  f x = (joinrec j y = ... x ... in jump j x) + 1

One may be tempted to float j out to the top of f's RHS, but then the jump
would not be a tail call. Thus we keep track of a level called the *join
ceiling* past which join points are not allowed to float.

The troublesome thing is that, unlike most levels to which something might
float, there is not necessarily an identifier to which the join ceiling is
attached. Fortunately, if something is to be floated to a join ceiling, it must
be dropped at the *nearest* join ceiling. Thus each level is marked as to
whether it is a join ceiling, so that FloatOut can tell which binders are being
floated to the nearest join ceiling and which to a particular binder (or set of
binders).
-}</span><span>
</span><span id="line-226"></span><span>
</span><span id="line-227"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680962928"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#FloatSpec"><span class="hs-identifier hs-type">FloatSpec</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-228"></span><span>  </span><span id="local-6989586621680962924"><span class="annot"><span class="annottext">ppr :: FloatSpec -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#FloatMe"><span class="hs-identifier hs-type">FloatMe</span></a></span><span> </span><span id="local-6989586621680962922"><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962922"><span class="hs-identifier hs-var">l</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Char -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#char"><span class="hs-identifier hs-var">char</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'F'</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Level -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962922"><span class="hs-identifier hs-var">l</span></a></span><span>
</span><span id="line-229"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#StayPut"><span class="hs-identifier hs-type">StayPut</span></a></span><span> </span><span id="local-6989586621680962919"><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962919"><span class="hs-identifier hs-var">l</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962919"><span class="hs-identifier hs-var">l</span></a></span><span>
</span><span id="line-230"></span><span>
</span><span id="line-231"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#tOP_LEVEL"><span class="hs-identifier hs-type">tOP_LEVEL</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span>
</span><span id="line-232"></span><span id="tOP_LEVEL"><span class="annot"><span class="annottext">tOP_LEVEL :: Level
</span><a href="GHC.Core.Opt.SetLevels.html#tOP_LEVEL"><span class="hs-identifier hs-var hs-var">tOP_LEVEL</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; LevelType -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-var">Level</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">LevelType
</span><a href="GHC.Core.Opt.SetLevels.html#BndrLvl"><span class="hs-identifier hs-var">BndrLvl</span></a></span><span>
</span><span id="line-233"></span><span>
</span><span id="line-234"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#incMajorLvl"><span class="hs-identifier hs-type">incMajorLvl</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span>
</span><span id="line-235"></span><span id="incMajorLvl"><span class="annot"><span class="annottext">incMajorLvl :: Level -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#incMajorLvl"><span class="hs-identifier hs-var hs-var">incMajorLvl</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span id="local-6989586621680962917"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962917"><span class="hs-identifier hs-var">major</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">LevelType
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; LevelType -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-var">Level</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962917"><span class="hs-identifier hs-var">major</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">LevelType
</span><a href="GHC.Core.Opt.SetLevels.html#BndrLvl"><span class="hs-identifier hs-var">BndrLvl</span></a></span><span>
</span><span id="line-236"></span><span>
</span><span id="line-237"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#incMinorLvl"><span class="hs-identifier hs-type">incMinorLvl</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span>
</span><span id="line-238"></span><span id="incMinorLvl"><span class="annot"><span class="annottext">incMinorLvl :: Level -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#incMinorLvl"><span class="hs-identifier hs-var hs-var">incMinorLvl</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span id="local-6989586621680962915"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962915"><span class="hs-identifier hs-var">major</span></a></span></span><span> </span><span id="local-6989586621680962914"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962914"><span class="hs-identifier hs-var">minor</span></a></span></span><span> </span><span class="annot"><span class="annottext">LevelType
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; LevelType -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-var">Level</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962915"><span class="hs-identifier hs-var">major</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962914"><span class="hs-identifier hs-var">minor</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LevelType
</span><a href="GHC.Core.Opt.SetLevels.html#BndrLvl"><span class="hs-identifier hs-var">BndrLvl</span></a></span><span>
</span><span id="line-239"></span><span>
</span><span id="line-240"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#asJoinCeilLvl"><span class="hs-identifier hs-type">asJoinCeilLvl</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span>
</span><span id="line-241"></span><span id="asJoinCeilLvl"><span class="annot"><span class="annottext">asJoinCeilLvl :: Level -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#asJoinCeilLvl"><span class="hs-identifier hs-var hs-var">asJoinCeilLvl</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span id="local-6989586621680962913"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962913"><span class="hs-identifier hs-var">major</span></a></span></span><span> </span><span id="local-6989586621680962912"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962912"><span class="hs-identifier hs-var">minor</span></a></span></span><span> </span><span class="annot"><span class="annottext">LevelType
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; LevelType -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-var">Level</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962913"><span class="hs-identifier hs-var">major</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962912"><span class="hs-identifier hs-var">minor</span></a></span><span> </span><span class="annot"><span class="annottext">LevelType
</span><a href="GHC.Core.Opt.SetLevels.html#JoinCeilLvl"><span class="hs-identifier hs-var">JoinCeilLvl</span></a></span><span>
</span><span id="line-242"></span><span>
</span><span id="line-243"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#maxLvl"><span class="hs-identifier hs-type">maxLvl</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span>
</span><span id="line-244"></span><span id="maxLvl"><span class="annot"><span class="annottext">maxLvl :: Level -&gt; Level -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#maxLvl"><span class="hs-identifier hs-var hs-var">maxLvl</span></a></span></span><span> </span><span id="local-6989586621680962910"><span class="annot"><span class="annottext">l1 :: Level
</span><a href="#local-6989586621680962910"><span class="hs-identifier hs-var">l1</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span id="local-6989586621680962909"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962909"><span class="hs-identifier hs-var">maj1</span></a></span></span><span> </span><span id="local-6989586621680962908"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962908"><span class="hs-identifier hs-var">min1</span></a></span></span><span> </span><span class="annot"><span class="annottext">LevelType
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680962907"><span class="annot"><span class="annottext">l2 :: Level
</span><a href="#local-6989586621680962907"><span class="hs-identifier hs-var">l2</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span id="local-6989586621680962906"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962906"><span class="hs-identifier hs-var">maj2</span></a></span></span><span> </span><span id="local-6989586621680962905"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962905"><span class="hs-identifier hs-var">min2</span></a></span></span><span> </span><span class="annot"><span class="annottext">LevelType
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>
</span><span id="line-245"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962909"><span class="hs-identifier hs-var">maj1</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962906"><span class="hs-identifier hs-var">maj2</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962909"><span class="hs-identifier hs-var">maj1</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962906"><span class="hs-identifier hs-var">maj2</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962908"><span class="hs-identifier hs-var">min1</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962905"><span class="hs-identifier hs-var">min2</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962910"><span class="hs-identifier hs-var">l1</span></a></span><span>
</span><span id="line-246"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                                      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962907"><span class="hs-identifier hs-var">l2</span></a></span><span>
</span><span id="line-247"></span><span>
</span><span id="line-248"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#ltLvl"><span class="hs-identifier hs-type">ltLvl</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-249"></span><span id="ltLvl"><span class="annot"><span class="annottext">ltLvl :: Level -&gt; Level -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#ltLvl"><span class="hs-identifier hs-var hs-var">ltLvl</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span id="local-6989586621680962901"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962901"><span class="hs-identifier hs-var">maj1</span></a></span></span><span> </span><span id="local-6989586621680962900"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962900"><span class="hs-identifier hs-var">min1</span></a></span></span><span> </span><span class="annot"><span class="annottext">LevelType
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span id="local-6989586621680962899"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962899"><span class="hs-identifier hs-var">maj2</span></a></span></span><span> </span><span id="local-6989586621680962898"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962898"><span class="hs-identifier hs-var">min2</span></a></span></span><span> </span><span class="annot"><span class="annottext">LevelType
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>
</span><span id="line-250"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962901"><span class="hs-identifier hs-var">maj1</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962899"><span class="hs-identifier hs-var">maj2</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962901"><span class="hs-identifier hs-var">maj1</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962899"><span class="hs-identifier hs-var">maj2</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962900"><span class="hs-identifier hs-var">min1</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962898"><span class="hs-identifier hs-var">min2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-251"></span><span>
</span><span id="line-252"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#ltMajLvl"><span class="hs-identifier hs-type">ltMajLvl</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-253"></span><span>    </span><span class="hs-comment">-- Tells if one level belongs to a difft *lambda* level to another</span><span>
</span><span id="line-254"></span><span id="ltMajLvl"><span class="annot"><span class="annottext">ltMajLvl :: Level -&gt; Level -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#ltMajLvl"><span class="hs-identifier hs-var hs-var">ltMajLvl</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span id="local-6989586621680962896"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962896"><span class="hs-identifier hs-var">maj1</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">LevelType
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span id="local-6989586621680962895"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962895"><span class="hs-identifier hs-var">maj2</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">LevelType
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962896"><span class="hs-identifier hs-var">maj1</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962895"><span class="hs-identifier hs-var">maj2</span></a></span><span>
</span><span id="line-255"></span><span>
</span><span id="line-256"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#isTopLvl"><span class="hs-identifier hs-type">isTopLvl</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-257"></span><span id="isTopLvl"><span class="annot"><span class="annottext">isTopLvl :: Level -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#isTopLvl"><span class="hs-identifier hs-var hs-var">isTopLvl</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">LevelType
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-258"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#isTopLvl"><span class="hs-identifier hs-var">isTopLvl</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><span class="hs-identifier">_</span></span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-259"></span><span>
</span><span id="line-260"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#isJoinCeilLvl"><span class="hs-identifier hs-type">isJoinCeilLvl</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-261"></span><span id="isJoinCeilLvl"><span class="annot"><span class="annottext">isJoinCeilLvl :: Level -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#isJoinCeilLvl"><span class="hs-identifier hs-var hs-var">isJoinCeilLvl</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680962894"><span class="annot"><span class="annottext">LevelType
</span><a href="#local-6989586621680962894"><span class="hs-identifier hs-var">t</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelType
</span><a href="#local-6989586621680962894"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="annot"><span class="annottext">LevelType -&gt; LevelType -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">LevelType
</span><a href="GHC.Core.Opt.SetLevels.html#JoinCeilLvl"><span class="hs-identifier hs-var">JoinCeilLvl</span></a></span><span>
</span><span id="line-262"></span><span>
</span><span id="line-263"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680962891"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-264"></span><span>  </span><span id="local-6989586621680962889"><span class="annot"><span class="annottext">ppr :: Level -&gt; SDoc
</span><a href="#local-6989586621680962889"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span id="local-6989586621680962888"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962888"><span class="hs-identifier hs-var">maj</span></a></span></span><span> </span><span id="local-6989586621680962887"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962887"><span class="hs-identifier hs-var">min</span></a></span></span><span> </span><span id="local-6989586621680962886"><span class="annot"><span class="annottext">LevelType
</span><a href="#local-6989586621680962886"><span class="hs-identifier hs-var">typ</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-265"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hcat"><span class="hs-identifier hs-var">hcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Char -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#char"><span class="hs-identifier hs-var">char</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'&lt;'</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#int"><span class="hs-identifier hs-var">int</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962888"><span class="hs-identifier hs-var">maj</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Char -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#char"><span class="hs-identifier hs-var">char</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">','</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#int"><span class="hs-identifier hs-var">int</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962887"><span class="hs-identifier hs-var">min</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Char -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#char"><span class="hs-identifier hs-var">char</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'&gt;'</span></span><span>
</span><span id="line-266"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppWhen"><span class="hs-identifier hs-var">ppWhen</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelType
</span><a href="#local-6989586621680962886"><span class="hs-identifier hs-var">typ</span></a></span><span> </span><span class="annot"><span class="annottext">LevelType -&gt; LevelType -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">LevelType
</span><a href="GHC.Core.Opt.SetLevels.html#JoinCeilLvl"><span class="hs-identifier hs-var">JoinCeilLvl</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#char"><span class="hs-identifier hs-var">char</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'C'</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-267"></span><span>
</span><span id="line-268"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680962880"><span class="annot"><span class="hs-identifier hs-type">Eq</span></span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-269"></span><span>  </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span id="local-6989586621680962877"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962877"><span class="hs-identifier hs-var">maj1</span></a></span></span><span> </span><span id="local-6989586621680962876"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962876"><span class="hs-identifier hs-var">min1</span></a></span></span><span> </span><span class="annot"><span class="annottext">LevelType
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680962875"><span class="annot"><span class="annottext">== :: Level -&gt; Level -&gt; Bool
</span><span class="hs-operator hs-var hs-var hs-var hs-var">==</span></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span id="local-6989586621680962874"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962874"><span class="hs-identifier hs-var">maj2</span></a></span></span><span> </span><span id="local-6989586621680962873"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962873"><span class="hs-identifier hs-var">min2</span></a></span></span><span> </span><span class="annot"><span class="annottext">LevelType
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962877"><span class="hs-identifier hs-var">maj1</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962874"><span class="hs-identifier hs-var">maj2</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962876"><span class="hs-identifier hs-var">min1</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962873"><span class="hs-identifier hs-var">min2</span></a></span><span>
</span><span id="line-270"></span><span>
</span><span id="line-271"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
\subsection{Main level-setting code}
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-278"></span><span>
</span><span id="line-279"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#setLevels"><span class="hs-identifier hs-type">setLevels</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Monad.html#FloatOutSwitches"><span class="hs-identifier hs-type">FloatOutSwitches</span></a></span><span>
</span><span id="line-280"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreProgram"><span class="hs-identifier hs-type">CoreProgram</span></a></span><span>
</span><span id="line-281"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Supply.html#UniqSupply"><span class="hs-identifier hs-type">UniqSupply</span></a></span><span>
</span><span id="line-282"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelledBind"><span class="hs-identifier hs-type">LevelledBind</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-283"></span><span>
</span><span id="line-284"></span><span id="setLevels"><span class="annot"><span class="annottext">setLevels :: FloatOutSwitches -&gt; CoreProgram -&gt; UniqSupply -&gt; [LevelledBind]
</span><a href="GHC.Core.Opt.SetLevels.html#setLevels"><span class="hs-identifier hs-var hs-var">setLevels</span></a></span></span><span> </span><span id="local-6989586621680962872"><span class="annot"><span class="annottext">FloatOutSwitches
</span><a href="#local-6989586621680962872"><span class="hs-identifier hs-var">float_lams</span></a></span></span><span> </span><span id="local-6989586621680962871"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680962871"><span class="hs-identifier hs-var">binds</span></a></span></span><span> </span><span id="local-6989586621680962870"><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621680962870"><span class="hs-identifier hs-var">us</span></a></span></span><span>
</span><span id="line-285"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UniqSupply -&gt; UniqSM [LevelledBind] -&gt; [LevelledBind]
forall a. UniqSupply -&gt; UniqSM a -&gt; a
</span><a href="GHC.Core.Opt.SetLevels.html#initLvl"><span class="hs-identifier hs-var">initLvl</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621680962870"><span class="hs-identifier hs-var">us</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; CoreProgram -&gt; UniqSM [LevelledBind]
</span><a href="#local-6989586621680962868"><span class="hs-identifier hs-var">do_them</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962867"><span class="hs-identifier hs-var">init_env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680962871"><span class="hs-identifier hs-var">binds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-286"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-287"></span><span>    </span><span id="local-6989586621680962867"><span class="annot"><span class="annottext">init_env :: LevelEnv
</span><a href="#local-6989586621680962867"><span class="hs-identifier hs-var hs-var">init_env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FloatOutSwitches -&gt; LevelEnv
</span><a href="GHC.Core.Opt.SetLevels.html#initialEnv"><span class="hs-identifier hs-var">initialEnv</span></a></span><span> </span><span class="annot"><span class="annottext">FloatOutSwitches
</span><a href="#local-6989586621680962872"><span class="hs-identifier hs-var">float_lams</span></a></span><span>
</span><span id="line-288"></span><span>
</span><span id="line-289"></span><span>    </span><span class="annot"><a href="#local-6989586621680962868"><span class="hs-identifier hs-type">do_them</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LvlM"><span class="hs-identifier hs-type">LvlM</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelledBind"><span class="hs-identifier hs-type">LevelledBind</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-290"></span><span>    </span><span id="local-6989586621680962868"><span class="annot"><span class="annottext">do_them :: LevelEnv -&gt; CoreProgram -&gt; UniqSM [LevelledBind]
</span><a href="#local-6989586621680962868"><span class="hs-identifier hs-var hs-var">do_them</span></a></span></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[LevelledBind] -&gt; UniqSM [LevelledBind]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-291"></span><span>    </span><span class="annot"><a href="#local-6989586621680962868"><span class="hs-identifier hs-var">do_them</span></a></span><span> </span><span id="local-6989586621680962865"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962865"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680962864"><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680962864"><span class="hs-identifier hs-var">b</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680962863"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680962863"><span class="hs-identifier hs-var">bs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-292"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680962862"><span class="annot"><span class="annottext">LevelledBind
</span><a href="#local-6989586621680962862"><span class="hs-identifier hs-var">lvld_bind</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962861"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962861"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; CoreBind -&gt; LvlM (LevelledBind, LevelEnv)
</span><a href="GHC.Core.Opt.SetLevels.html#lvlTopBind"><span class="hs-identifier hs-var">lvlTopBind</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962865"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680962864"><span class="hs-identifier hs-var">b</span></a></span><span>
</span><span id="line-293"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621680962859"><span class="annot"><span class="annottext">[LevelledBind]
</span><a href="#local-6989586621680962859"><span class="hs-identifier hs-var">lvld_binds</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; CoreProgram -&gt; UniqSM [LevelledBind]
</span><a href="#local-6989586621680962868"><span class="hs-identifier hs-var">do_them</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962861"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680962863"><span class="hs-identifier hs-var">bs</span></a></span><span>
</span><span id="line-294"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[LevelledBind] -&gt; UniqSM [LevelledBind]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelledBind
</span><a href="#local-6989586621680962862"><span class="hs-identifier hs-var">lvld_bind</span></a></span><span> </span><span class="annot"><span class="annottext">LevelledBind -&gt; [LevelledBind] -&gt; [LevelledBind]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[LevelledBind]
</span><a href="#local-6989586621680962859"><span class="hs-identifier hs-var">lvld_binds</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-295"></span><span>
</span><span id="line-296"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#lvlTopBind"><span class="hs-identifier hs-type">lvlTopBind</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#Bind"><span class="hs-identifier hs-type">Bind</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LvlM"><span class="hs-identifier hs-type">LvlM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelledBind"><span class="hs-identifier hs-type">LevelledBind</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-297"></span><span id="lvlTopBind"><span class="annot"><span class="annottext">lvlTopBind :: LevelEnv -&gt; CoreBind -&gt; LvlM (LevelledBind, LevelEnv)
</span><a href="GHC.Core.Opt.SetLevels.html#lvlTopBind"><span class="hs-identifier hs-var hs-var">lvlTopBind</span></a></span></span><span> </span><span id="local-6989586621680962858"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962858"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-type">NonRec</span></a></span><span> </span><span id="local-6989586621680962856"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962856"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621680962855"><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621680962855"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-298"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680962854"><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962854"><span class="hs-identifier hs-var">rhs'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; RecFlag -&gt; Id -&gt; Expr Id -&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvl_top"><span class="hs-identifier hs-var">lvl_top</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962858"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="GHC.Types.Basic.html#NonRecursive"><span class="hs-identifier hs-var">NonRecursive</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962856"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621680962855"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-299"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680962851"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962851"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span id="local-6989586621680962850"><span class="annot"><span class="annottext">LevelledBndr
</span><a href="#local-6989586621680962850"><span class="hs-identifier hs-var">bndr'</span></a></span></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RecFlag -&gt; LevelEnv -&gt; Level -&gt; [Id] -&gt; (LevelEnv, [LevelledBndr])
</span><a href="GHC.Core.Opt.SetLevels.html#substAndLvlBndrs"><span class="hs-identifier hs-var">substAndLvlBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="GHC.Types.Basic.html#NonRecursive"><span class="hs-identifier hs-var">NonRecursive</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962858"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="GHC.Core.Opt.SetLevels.html#tOP_LEVEL"><span class="hs-identifier hs-var">tOP_LEVEL</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962856"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-300"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(LevelledBind, LevelEnv) -&gt; LvlM (LevelledBind, LevelEnv)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelledBndr -&gt; LevelledExpr -&gt; LevelledBind
forall b. b -&gt; Expr b -&gt; Bind b
</span><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-var">NonRec</span></a></span><span> </span><span class="annot"><span class="annottext">LevelledBndr
</span><a href="#local-6989586621680962850"><span class="hs-identifier hs-var">bndr'</span></a></span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962854"><span class="hs-identifier hs-var">rhs'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962851"><span class="hs-identifier hs-var">env'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-301"></span><span>
</span><span id="line-302"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#lvlTopBind"><span class="hs-identifier hs-var">lvlTopBind</span></a></span><span> </span><span id="local-6989586621680962848"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962848"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-type">Rec</span></a></span><span> </span><span id="local-6989586621680962846"><span class="annot"><span class="annottext">[(Id, Expr Id)]
</span><a href="#local-6989586621680962846"><span class="hs-identifier hs-var">pairs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-303"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680962845"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962845"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962844"><span class="annot"><span class="annottext">[LevelledBndr]
</span><a href="#local-6989586621680962844"><span class="hs-identifier hs-var">bndrs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RecFlag -&gt; LevelEnv -&gt; Level -&gt; [Id] -&gt; (LevelEnv, [LevelledBndr])
</span><a href="GHC.Core.Opt.SetLevels.html#substAndLvlBndrs"><span class="hs-identifier hs-var">substAndLvlBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="GHC.Types.Basic.html#Recursive"><span class="hs-identifier hs-var">Recursive</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962848"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="GHC.Core.Opt.SetLevels.html#tOP_LEVEL"><span class="hs-identifier hs-var">tOP_LEVEL</span></a></span><span>
</span><span id="line-304"></span><span>                                               </span><span class="hs-special">(</span><span class="annot"><span class="annottext">((Id, Expr Id) -&gt; Id) -&gt; [(Id, Expr Id)] -&gt; [Id]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(Id, Expr Id) -&gt; Id
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, Expr Id)]
</span><a href="#local-6989586621680962846"><span class="hs-identifier hs-var">pairs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-305"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621680962842"><span class="annot"><span class="annottext">[LevelledExpr]
</span><a href="#local-6989586621680962842"><span class="hs-identifier hs-var">rhss'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">((Id, Expr Id) -&gt; LvlM LevelledExpr)
-&gt; [(Id, Expr Id)] -&gt; UniqSM [LevelledExpr]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-special">(</span><span id="local-6989586621680962840"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962840"><span class="hs-identifier hs-var">b</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680962839"><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621680962839"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; RecFlag -&gt; Id -&gt; Expr Id -&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvl_top"><span class="hs-identifier hs-var">lvl_top</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962845"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="GHC.Types.Basic.html#Recursive"><span class="hs-identifier hs-var">Recursive</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962840"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621680962839"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(Id, Expr Id)]
</span><a href="#local-6989586621680962846"><span class="hs-identifier hs-var">pairs</span></a></span><span>
</span><span id="line-306"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(LevelledBind, LevelEnv) -&gt; LvlM (LevelledBind, LevelEnv)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(LevelledBndr, LevelledExpr)] -&gt; LevelledBind
forall b. [(b, Expr b)] -&gt; Bind b
</span><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-var">Rec</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[LevelledBndr]
</span><a href="#local-6989586621680962844"><span class="hs-identifier hs-var">bndrs'</span></a></span><span> </span><span class="annot"><span class="annottext">[LevelledBndr] -&gt; [LevelledExpr] -&gt; [(LevelledBndr, LevelledExpr)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-operator hs-var">`zip`</span></a></span><span> </span><span class="annot"><span class="annottext">[LevelledExpr]
</span><a href="#local-6989586621680962842"><span class="hs-identifier hs-var">rhss'</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962845"><span class="hs-identifier hs-var">env'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-307"></span><span>
</span><span id="line-308"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#lvl_top"><span class="hs-identifier hs-type">lvl_top</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#RecFlag"><span class="hs-identifier hs-type">RecFlag</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LvlM"><span class="hs-identifier hs-type">LvlM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelledExpr"><span class="hs-identifier hs-type">LevelledExpr</span></a></span><span>
</span><span id="line-309"></span><span id="lvl_top"><span class="annot"><span class="annottext">lvl_top :: LevelEnv -&gt; RecFlag -&gt; Id -&gt; Expr Id -&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvl_top"><span class="hs-identifier hs-var hs-var">lvl_top</span></a></span></span><span> </span><span id="local-6989586621680962837"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962837"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680962836"><span class="annot"><span class="annottext">RecFlag
</span><a href="#local-6989586621680962836"><span class="hs-identifier hs-var">is_rec</span></a></span></span><span> </span><span id="local-6989586621680962835"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962835"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621680962834"><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621680962834"><span class="hs-identifier hs-var">rhs</span></a></span></span><span>
</span><span id="line-310"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelEnv
-&gt; RecFlag
-&gt; Bool
-&gt; Maybe Int
-&gt; CoreExprWithFVs
-&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlRhs"><span class="hs-identifier hs-var">lvlRhs</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962837"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="#local-6989586621680962836"><span class="hs-identifier hs-var">is_rec</span></a></span><span>
</span><span id="line-311"></span><span>           </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Id.html#isDeadEndId"><span class="hs-identifier hs-var">isDeadEndId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962835"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-312"></span><span>           </span><span class="annot"><span class="annottext">Maybe Int
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>  </span><span class="hs-comment">-- Not a join point</span><span>
</span><span id="line-313"></span><span>           </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Expr Id -&gt; CoreExprWithFVs
</span><a href="GHC.Core.FVs.html#freeVars"><span class="hs-identifier hs-var">freeVars</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621680962834"><span class="hs-identifier hs-var">rhs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-314"></span><span>
</span><span id="line-315"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
\subsection{Setting expression levels}
*                                                                      *
************************************************************************

Note [Floating over-saturated applications]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If we see (f x y), and (f x) is a redex (ie f's arity is 1),
we call (f x) an &quot;over-saturated application&quot;

Should we float out an over-sat app, if can escape a value lambda?
It is sometimes very beneficial (-7% runtime -4% alloc over nofib -O2).
But we don't want to do it for class selectors, because the work saved
is minimal, and the extra local thunks allocated cost money.

Arguably we could float even class-op applications if they were going to
top level -- but then they must be applied to a constant dictionary and
will almost certainly be optimised away anyway.
-}</span><span>
</span><span id="line-336"></span><span>
</span><span id="line-337"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#lvlExpr"><span class="hs-identifier hs-type">lvlExpr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span>             </span><span class="hs-comment">-- Context</span><span>
</span><span id="line-338"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.FVs.html#CoreExprWithFVs"><span class="hs-identifier hs-type">CoreExprWithFVs</span></a></span><span>      </span><span class="hs-comment">-- Input expression</span><span>
</span><span id="line-339"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LvlM"><span class="hs-identifier hs-type">LvlM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelledExpr"><span class="hs-identifier hs-type">LevelledExpr</span></a></span><span>    </span><span class="hs-comment">-- Result expression</span><span>
</span><span id="line-340"></span><span>
</span><span id="line-341"></span><span class="hs-comment">{-
The @le_ctxt_lvl@ is, roughly, the level of the innermost enclosing
binder.  Here's an example

        v = \x -&gt; ...\y -&gt; let r = case (..x..) of
                                        ..x..
                           in ..

When looking at the rhs of @r@, @le_ctxt_lvl@ will be 1 because that's
the level of @r@, even though it's inside a level-2 @\y@.  It's
important that @le_ctxt_lvl@ is 1 and not 2 in @r@'s rhs, because we
don't want @lvlExpr@ to turn the scrutinee of the @case@ into an MFE
--- because it isn't a *maximal* free expression.

If there were another lambda in @r@'s rhs, it would get level-2 as well.
-}</span><span>
</span><span id="line-357"></span><span>
</span><span id="line-358"></span><span id="lvlExpr"><span class="annot"><span class="annottext">lvlExpr :: LevelEnv -&gt; CoreExprWithFVs -&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlExpr"><span class="hs-identifier hs-var hs-var">lvlExpr</span></a></span></span><span> </span><span id="local-6989586621680962829"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962829"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FVAnn
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#AnnType"><span class="hs-identifier hs-type">AnnType</span></a></span><span> </span><span id="local-6989586621680962827"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680962827"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelledExpr -&gt; LvlM LevelledExpr
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; LevelledExpr
forall b. Type -&gt; Expr b
</span><a href="GHC.Core.html#Type"><span class="hs-identifier hs-var">Type</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst -&gt; Type -&gt; Type
</span><a href="GHC.Core.Subst.html#substTy"><span class="hs-identifier hs-var">GHC.Core.Subst.substTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; Subst
</span><a href="GHC.Core.Opt.SetLevels.html#le_subst"><span class="hs-identifier hs-var hs-var">le_subst</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962829"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680962827"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-359"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#lvlExpr"><span class="hs-identifier hs-var">lvlExpr</span></a></span><span> </span><span id="local-6989586621680962823"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962823"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FVAnn
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#AnnCoercion"><span class="hs-identifier hs-type">AnnCoercion</span></a></span><span> </span><span id="local-6989586621680962821"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680962821"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelledExpr -&gt; LvlM LevelledExpr
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; LevelledExpr
forall b. Coercion -&gt; Expr b
</span><a href="GHC.Core.html#Coercion"><span class="hs-identifier hs-var">Coercion</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasCallStack =&gt; Subst -&gt; Coercion -&gt; Coercion
Subst -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Subst.html#substCo"><span class="hs-identifier hs-var">substCo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; Subst
</span><a href="GHC.Core.Opt.SetLevels.html#le_subst"><span class="hs-identifier hs-var hs-var">le_subst</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962823"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680962821"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-360"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#lvlExpr"><span class="hs-identifier hs-var">lvlExpr</span></a></span><span> </span><span id="local-6989586621680962818"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962818"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FVAnn
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#AnnVar"><span class="hs-identifier hs-type">AnnVar</span></a></span><span> </span><span id="local-6989586621680962816"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962816"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">)</span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelledExpr -&gt; LvlM LevelledExpr
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; Id -&gt; LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lookupVar"><span class="hs-identifier hs-var">lookupVar</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962818"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962816"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-361"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#lvlExpr"><span class="hs-identifier hs-var">lvlExpr</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><span class="hs-identifier">_</span></span><span>   </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FVAnn
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#AnnLit"><span class="hs-identifier hs-type">AnnLit</span></a></span><span> </span><span id="local-6989586621680962813"><span class="annot"><span class="annottext">Literal
</span><a href="#local-6989586621680962813"><span class="hs-identifier hs-var">lit</span></a></span></span><span class="hs-special">)</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelledExpr -&gt; LvlM LevelledExpr
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Literal -&gt; LevelledExpr
forall b. Literal -&gt; Expr b
</span><a href="GHC.Core.html#Lit"><span class="hs-identifier hs-var">Lit</span></a></span><span> </span><span class="annot"><span class="annottext">Literal
</span><a href="#local-6989586621680962813"><span class="hs-identifier hs-var">lit</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-362"></span><span>
</span><span id="line-363"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#lvlExpr"><span class="hs-identifier hs-var">lvlExpr</span></a></span><span> </span><span id="local-6989586621680962811"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962811"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FVAnn
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#AnnCast"><span class="hs-identifier hs-type">AnnCast</span></a></span><span> </span><span id="local-6989586621680962809"><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962809"><span class="hs-identifier hs-var">expr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FVAnn
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962808"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680962808"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-364"></span><span>    </span><span id="local-6989586621680962807"><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962807"><span class="hs-identifier hs-var">expr'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; CoreExprWithFVs -&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlNonTailExpr"><span class="hs-identifier hs-var">lvlNonTailExpr</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962811"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962809"><span class="hs-identifier hs-var">expr</span></a></span><span>
</span><span id="line-365"></span><span>    </span><span class="annot"><span class="annottext">LevelledExpr -&gt; LvlM LevelledExpr
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelledExpr -&gt; Coercion -&gt; LevelledExpr
forall b. Expr b -&gt; Coercion -&gt; Expr b
</span><a href="GHC.Core.html#Cast"><span class="hs-identifier hs-var">Cast</span></a></span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962807"><span class="hs-identifier hs-var">expr'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasCallStack =&gt; Subst -&gt; Coercion -&gt; Coercion
Subst -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Subst.html#substCo"><span class="hs-identifier hs-var">substCo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; Subst
</span><a href="GHC.Core.Opt.SetLevels.html#le_subst"><span class="hs-identifier hs-var hs-var">le_subst</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962811"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680962808"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-366"></span><span>
</span><span id="line-367"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#lvlExpr"><span class="hs-identifier hs-var">lvlExpr</span></a></span><span> </span><span id="local-6989586621680962804"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962804"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FVAnn
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#AnnTick"><span class="hs-identifier hs-type">AnnTick</span></a></span><span> </span><span id="local-6989586621680962802"><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621680962802"><span class="hs-identifier hs-var">tickish</span></a></span></span><span> </span><span id="local-6989586621680962801"><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962801"><span class="hs-identifier hs-var">expr</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-368"></span><span>    </span><span id="local-6989586621680962800"><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962800"><span class="hs-identifier hs-var">expr'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; CoreExprWithFVs -&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlNonTailExpr"><span class="hs-identifier hs-var">lvlNonTailExpr</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962804"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962801"><span class="hs-identifier hs-var">expr</span></a></span><span>
</span><span id="line-369"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680962799"><span class="annot"><span class="annottext">tickish' :: Tickish Id
</span><a href="#local-6989586621680962799"><span class="hs-identifier hs-var hs-var">tickish'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; Tickish Id -&gt; Tickish Id
</span><a href="GHC.Core.Subst.html#substTickish"><span class="hs-identifier hs-var">substTickish</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; Subst
</span><a href="GHC.Core.Opt.SetLevels.html#le_subst"><span class="hs-identifier hs-var hs-var">le_subst</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962804"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621680962802"><span class="hs-identifier hs-var">tickish</span></a></span><span>
</span><span id="line-370"></span><span>    </span><span class="annot"><span class="annottext">LevelledExpr -&gt; LvlM LevelledExpr
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tickish Id -&gt; LevelledExpr -&gt; LevelledExpr
forall b. Tickish Id -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Tick"><span class="hs-identifier hs-var">Tick</span></a></span><span> </span><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621680962799"><span class="hs-identifier hs-var">tickish'</span></a></span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962800"><span class="hs-identifier hs-var">expr'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-371"></span><span>
</span><span id="line-372"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#lvlExpr"><span class="hs-identifier hs-var">lvlExpr</span></a></span><span> </span><span id="local-6989586621680962796"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962796"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680962795"><span class="annot"><span class="annottext">expr :: CoreExprWithFVs
</span><a href="#local-6989586621680962795"><span class="hs-identifier hs-var">expr</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><span class="annottext">FVAnn
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#AnnApp"><span class="hs-identifier hs-type">AnnApp</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelEnv
-&gt; CoreExprWithFVs
-&gt; (CoreExprWithFVs, [CoreExprWithFVs])
-&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlApp"><span class="hs-identifier hs-var">lvlApp</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962796"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962795"><span class="hs-identifier hs-var">expr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExprWithFVs -&gt; (CoreExprWithFVs, [CoreExprWithFVs])
forall b a. AnnExpr b a -&gt; (AnnExpr b a, [AnnExpr b a])
</span><a href="GHC.Core.html#collectAnnArgs"><span class="hs-identifier hs-var">collectAnnArgs</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962795"><span class="hs-identifier hs-var">expr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-373"></span><span>
</span><span id="line-374"></span><span class="hs-comment">-- We don't split adjacent lambdas.  That is, given</span><span>
</span><span id="line-375"></span><span class="hs-comment">--      \x y -&gt; (x+1,y)</span><span>
</span><span id="line-376"></span><span class="hs-comment">-- we don't float to give</span><span>
</span><span id="line-377"></span><span class="hs-comment">--      \x -&gt; let v = x+1 in \y -&gt; (v,y)</span><span>
</span><span id="line-378"></span><span class="hs-comment">-- Why not?  Because partial applications are fairly rare, and splitting</span><span>
</span><span id="line-379"></span><span class="hs-comment">-- lambdas makes them more expensive.</span><span>
</span><span id="line-380"></span><span>
</span><span id="line-381"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#lvlExpr"><span class="hs-identifier hs-var">lvlExpr</span></a></span><span> </span><span id="local-6989586621680962791"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962791"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680962790"><span class="annot"><span class="annottext">expr :: CoreExprWithFVs
</span><a href="#local-6989586621680962790"><span class="hs-identifier hs-var">expr</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><span class="annottext">FVAnn
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#AnnLam"><span class="hs-identifier hs-type">AnnLam</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-382"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680962788"><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962788"><span class="hs-identifier hs-var">new_body</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Bool -&gt; CoreExprWithFVs -&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlNonTailMFE"><span class="hs-identifier hs-var">lvlNonTailMFE</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962786"><span class="hs-identifier hs-var">new_env</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962785"><span class="hs-identifier hs-var">body</span></a></span><span>
</span><span id="line-383"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">LevelledExpr -&gt; LvlM LevelledExpr
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[LevelledBndr] -&gt; LevelledExpr -&gt; LevelledExpr
forall b. [b] -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#mkLams"><span class="hs-identifier hs-var">mkLams</span></a></span><span> </span><span class="annot"><span class="annottext">[LevelledBndr]
</span><a href="#local-6989586621680962783"><span class="hs-identifier hs-var">new_bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962788"><span class="hs-identifier hs-var">new_body</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-384"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-385"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680962782"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962782"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962785"><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962785"><span class="hs-identifier hs-var">body</span></a></span></span><span class="hs-special">)</span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs -&gt; ([Id], CoreExprWithFVs)
forall bndr annot.
AnnExpr bndr annot -&gt; ([bndr], AnnExpr bndr annot)
</span><a href="GHC.Core.html#collectAnnBndrs"><span class="hs-identifier hs-var">collectAnnBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962790"><span class="hs-identifier hs-var">expr</span></a></span><span>
</span><span id="line-386"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680962780"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962780"><span class="hs-identifier hs-var">env1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962779"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962779"><span class="hs-identifier hs-var">bndrs1</span></a></span></span><span class="hs-special">)</span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RecFlag -&gt; LevelEnv -&gt; [Id] -&gt; (LevelEnv, [Id])
</span><a href="GHC.Core.Opt.SetLevels.html#substBndrsSL"><span class="hs-identifier hs-var">substBndrsSL</span></a></span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="GHC.Types.Basic.html#NonRecursive"><span class="hs-identifier hs-var">NonRecursive</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962791"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962782"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-387"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680962786"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962786"><span class="hs-identifier hs-var">new_env</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962783"><span class="annot"><span class="annottext">[LevelledBndr]
</span><a href="#local-6989586621680962783"><span class="hs-identifier hs-var">new_bndrs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Level -&gt; [Id] -&gt; (LevelEnv, [LevelledBndr])
</span><a href="GHC.Core.Opt.SetLevels.html#lvlLamBndrs"><span class="hs-identifier hs-var">lvlLamBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962780"><span class="hs-identifier hs-var">env1</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#le_ctxt_lvl"><span class="hs-identifier hs-var hs-var">le_ctxt_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962791"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962779"><span class="hs-identifier hs-var">bndrs1</span></a></span><span>
</span><span id="line-388"></span><span>        </span><span class="hs-comment">-- At one time we called a special version of collectBinders,</span><span>
</span><span id="line-389"></span><span>        </span><span class="hs-comment">-- which ignored coercions, because we don't want to split</span><span>
</span><span id="line-390"></span><span>        </span><span class="hs-comment">-- a lambda like this (\x -&gt; coerce t (\s -&gt; ...))</span><span>
</span><span id="line-391"></span><span>        </span><span class="hs-comment">-- This used to happen quite a bit in state-transformer programs,</span><span>
</span><span id="line-392"></span><span>        </span><span class="hs-comment">-- but not nearly so much now non-recursive newtypes are transparent.</span><span>
</span><span id="line-393"></span><span>        </span><span class="hs-comment">-- [See GHC.Core.Opt.SetLevels rev 1.50 for a version with this approach.]</span><span>
</span><span id="line-394"></span><span>
</span><span id="line-395"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#lvlExpr"><span class="hs-identifier hs-var">lvlExpr</span></a></span><span> </span><span id="local-6989586621680962775"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962775"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FVAnn
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#AnnLet"><span class="hs-identifier hs-type">AnnLet</span></a></span><span> </span><span id="local-6989586621680962773"><span class="annot"><span class="annottext">AnnBind Id FVAnn
</span><a href="#local-6989586621680962773"><span class="hs-identifier hs-var">bind</span></a></span></span><span> </span><span id="local-6989586621680962772"><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962772"><span class="hs-identifier hs-var">body</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-396"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680962771"><span class="annot"><span class="annottext">LevelledBind
</span><a href="#local-6989586621680962771"><span class="hs-identifier hs-var">bind'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962770"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962770"><span class="hs-identifier hs-var">new_env</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; AnnBind Id FVAnn -&gt; LvlM (LevelledBind, LevelEnv)
</span><a href="GHC.Core.Opt.SetLevels.html#lvlBind"><span class="hs-identifier hs-var">lvlBind</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962775"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">AnnBind Id FVAnn
</span><a href="#local-6989586621680962773"><span class="hs-identifier hs-var">bind</span></a></span><span>
</span><span id="line-397"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621680962768"><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962768"><span class="hs-identifier hs-var">body'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; CoreExprWithFVs -&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlExpr"><span class="hs-identifier hs-var">lvlExpr</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962770"><span class="hs-identifier hs-var">new_env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962772"><span class="hs-identifier hs-var">body</span></a></span><span>
</span><span id="line-398"></span><span>           </span><span class="hs-comment">-- No point in going via lvlMFE here.  If the binding is alive</span><span>
</span><span id="line-399"></span><span>           </span><span class="hs-comment">-- (mentioned in body), and the whole let-expression doesn't</span><span>
</span><span id="line-400"></span><span>           </span><span class="hs-comment">-- float, then neither will the body</span><span>
</span><span id="line-401"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">LevelledExpr -&gt; LvlM LevelledExpr
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelledBind -&gt; LevelledExpr -&gt; LevelledExpr
forall b. Bind b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Let"><span class="hs-identifier hs-var">Let</span></a></span><span> </span><span class="annot"><span class="annottext">LevelledBind
</span><a href="#local-6989586621680962771"><span class="hs-identifier hs-var">bind'</span></a></span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962768"><span class="hs-identifier hs-var">body'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-402"></span><span>
</span><span id="line-403"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#lvlExpr"><span class="hs-identifier hs-var">lvlExpr</span></a></span><span> </span><span id="local-6989586621680962766"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962766"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FVAnn
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#AnnCase"><span class="hs-identifier hs-type">AnnCase</span></a></span><span> </span><span id="local-6989586621680962764"><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962764"><span class="hs-identifier hs-var">scrut</span></a></span></span><span> </span><span id="local-6989586621680962763"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962763"><span class="hs-identifier hs-var">case_bndr</span></a></span></span><span> </span><span id="local-6989586621680962762"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680962762"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621680962761"><span class="annot"><span class="annottext">[AnnAlt Id FVAnn]
</span><a href="#local-6989586621680962761"><span class="hs-identifier hs-var">alts</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-404"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680962760"><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962760"><span class="hs-identifier hs-var">scrut'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Bool -&gt; CoreExprWithFVs -&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlNonTailMFE"><span class="hs-identifier hs-var">lvlNonTailMFE</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962766"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962764"><span class="hs-identifier hs-var">scrut</span></a></span><span>
</span><span id="line-405"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">LevelEnv
-&gt; FVAnn
-&gt; LevelledExpr
-&gt; Id
-&gt; Type
-&gt; [AnnAlt Id FVAnn]
-&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlCase"><span class="hs-identifier hs-var">lvlCase</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962766"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExprWithFVs -&gt; FVAnn
</span><a href="GHC.Core.FVs.html#freeVarsOf"><span class="hs-identifier hs-var">freeVarsOf</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962764"><span class="hs-identifier hs-var">scrut</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962760"><span class="hs-identifier hs-var">scrut'</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962763"><span class="hs-identifier hs-var">case_bndr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680962762"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">[AnnAlt Id FVAnn]
</span><a href="#local-6989586621680962761"><span class="hs-identifier hs-var">alts</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-406"></span><span>
</span><span id="line-407"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#lvlNonTailExpr"><span class="hs-identifier hs-type">lvlNonTailExpr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span>             </span><span class="hs-comment">-- Context</span><span>
</span><span id="line-408"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.FVs.html#CoreExprWithFVs"><span class="hs-identifier hs-type">CoreExprWithFVs</span></a></span><span>      </span><span class="hs-comment">-- Input expression</span><span>
</span><span id="line-409"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LvlM"><span class="hs-identifier hs-type">LvlM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelledExpr"><span class="hs-identifier hs-type">LevelledExpr</span></a></span><span>    </span><span class="hs-comment">-- Result expression</span><span>
</span><span id="line-410"></span><span id="lvlNonTailExpr"><span class="annot"><span class="annottext">lvlNonTailExpr :: LevelEnv -&gt; CoreExprWithFVs -&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlNonTailExpr"><span class="hs-identifier hs-var hs-var">lvlNonTailExpr</span></a></span></span><span> </span><span id="local-6989586621680962757"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962757"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680962756"><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962756"><span class="hs-identifier hs-var">expr</span></a></span></span><span>
</span><span id="line-411"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; CoreExprWithFVs -&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlExpr"><span class="hs-identifier hs-var">lvlExpr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; LevelEnv
</span><a href="GHC.Core.Opt.SetLevels.html#placeJoinCeiling"><span class="hs-identifier hs-var">placeJoinCeiling</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962757"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962756"><span class="hs-identifier hs-var">expr</span></a></span><span>
</span><span id="line-412"></span><span>
</span><span id="line-413"></span><span class="hs-comment">-------------------------------------------</span><span>
</span><span id="line-414"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#lvlApp"><span class="hs-identifier hs-type">lvlApp</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span>
</span><span id="line-415"></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.FVs.html#CoreExprWithFVs"><span class="hs-identifier hs-type">CoreExprWithFVs</span></a></span><span>
</span><span id="line-416"></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.FVs.html#CoreExprWithFVs"><span class="hs-identifier hs-type">CoreExprWithFVs</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.FVs.html#CoreExprWithFVs"><span class="hs-identifier hs-type">CoreExprWithFVs</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- Input application</span><span>
</span><span id="line-417"></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LvlM"><span class="hs-identifier hs-type">LvlM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelledExpr"><span class="hs-identifier hs-type">LevelledExpr</span></a></span><span>                    </span><span class="hs-comment">-- Result expression</span><span>
</span><span id="line-418"></span><span id="lvlApp"><span class="annot"><span class="annottext">lvlApp :: LevelEnv
-&gt; CoreExprWithFVs
-&gt; (CoreExprWithFVs, [CoreExprWithFVs])
-&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlApp"><span class="hs-identifier hs-var hs-var">lvlApp</span></a></span></span><span> </span><span id="local-6989586621680962754"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962754"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680962753"><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962753"><span class="hs-identifier hs-var">orig_expr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">FVAnn
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Core.html#AnnVar"><span class="hs-identifier hs-type">AnnVar</span></a></span><span> </span><span id="local-6989586621680962752"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962752"><span class="hs-identifier hs-var">fn</span></a></span></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962751"><span class="annot"><span class="annottext">[CoreExprWithFVs]
</span><a href="#local-6989586621680962751"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-419"></span><span>  </span><span class="hs-comment">-- Try to ensure that runRW#'s continuation isn't floated out.</span><span>
</span><span id="line-420"></span><span>  </span><span class="hs-comment">-- See Note [Simplification of runRW#].</span><span>
</span><span id="line-421"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962752"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Unique -&gt; Bool
forall a. Uniquable a =&gt; a -&gt; Unique -&gt; Bool
</span><a href="GHC.Types.Unique.html#hasKey"><span class="hs-operator hs-var">`hasKey`</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#runRWKey"><span class="hs-identifier hs-var">runRWKey</span></a></span><span>
</span><span id="line-422"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680962750"><span class="annot"><span class="annottext">[LevelledExpr]
</span><a href="#local-6989586621680962750"><span class="hs-identifier hs-var">args'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(CoreExprWithFVs -&gt; LvlM LevelledExpr)
-&gt; [CoreExprWithFVs] -&gt; UniqSM [LevelledExpr]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; CoreExprWithFVs -&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlExpr"><span class="hs-identifier hs-var">lvlExpr</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962754"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CoreExprWithFVs]
</span><a href="#local-6989586621680962751"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-423"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">LevelledExpr -&gt; LvlM LevelledExpr
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(LevelledExpr -&gt; LevelledExpr -&gt; LevelledExpr)
-&gt; LevelledExpr -&gt; [LevelledExpr] -&gt; LevelledExpr
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">LevelledExpr -&gt; LevelledExpr -&gt; LevelledExpr
forall b. Expr b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#App"><span class="hs-identifier hs-var">App</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; Id -&gt; LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lookupVar"><span class="hs-identifier hs-var">lookupVar</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962754"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962752"><span class="hs-identifier hs-var">fn</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[LevelledExpr]
</span><a href="#local-6989586621680962750"><span class="hs-identifier hs-var">args'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-424"></span><span>
</span><span id="line-425"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#floatOverSat"><span class="hs-identifier hs-var">floatOverSat</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962754"><span class="hs-identifier hs-var">env</span></a></span><span>   </span><span class="hs-comment">-- See Note [Floating over-saturated applications]</span><span>
</span><span id="line-426"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962746"><span class="hs-identifier hs-var">arity</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>
</span><span id="line-427"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962746"><span class="hs-identifier hs-var">arity</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962745"><span class="hs-identifier hs-var">n_val_args</span></a></span><span>
</span><span id="line-428"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe Class
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Maybe Class
</span><a href="GHC.Types.Id.html#isClassOpId_maybe"><span class="hs-identifier hs-var">isClassOpId_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962752"><span class="hs-identifier hs-var">fn</span></a></span><span>
</span><span id="line-429"></span><span>  </span><span class="hs-glyph">=</span><span>  </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680962743"><span class="annot"><span class="annottext">[LevelledExpr]
</span><a href="#local-6989586621680962743"><span class="hs-identifier hs-var">rargs'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(CoreExprWithFVs -&gt; LvlM LevelledExpr)
-&gt; [CoreExprWithFVs] -&gt; UniqSM [LevelledExpr]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; Bool -&gt; CoreExprWithFVs -&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlNonTailMFE"><span class="hs-identifier hs-var">lvlNonTailMFE</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962754"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CoreExprWithFVs]
</span><a href="#local-6989586621680962742"><span class="hs-identifier hs-var">rargs</span></a></span><span>
</span><span id="line-430"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621680962741"><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962741"><span class="hs-identifier hs-var">lapp'</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Bool -&gt; CoreExprWithFVs -&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlNonTailMFE"><span class="hs-identifier hs-var">lvlNonTailMFE</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962754"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962740"><span class="hs-identifier hs-var">lapp</span></a></span><span>
</span><span id="line-431"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">LevelledExpr -&gt; LvlM LevelledExpr
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(LevelledExpr -&gt; LevelledExpr -&gt; LevelledExpr)
-&gt; LevelledExpr -&gt; [LevelledExpr] -&gt; LevelledExpr
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">LevelledExpr -&gt; LevelledExpr -&gt; LevelledExpr
forall b. Expr b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#App"><span class="hs-identifier hs-var">App</span></a></span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962741"><span class="hs-identifier hs-var">lapp'</span></a></span><span> </span><span class="annot"><span class="annottext">[LevelledExpr]
</span><a href="#local-6989586621680962743"><span class="hs-identifier hs-var">rargs'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-432"></span><span>
</span><span id="line-433"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-434"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Demand]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962739"><span class="annot"><span class="annottext">[LevelledExpr]
</span><a href="#local-6989586621680962739"><span class="hs-identifier hs-var">args'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">([Demand] -&gt; CoreExprWithFVs -&gt; UniqSM ([Demand], LevelledExpr))
-&gt; [Demand]
-&gt; [CoreExprWithFVs]
-&gt; UniqSM ([Demand], [LevelledExpr])
forall (m :: * -&gt; *) acc x y.
Monad m =&gt;
(acc -&gt; x -&gt; m (acc, y)) -&gt; acc -&gt; [x] -&gt; m (acc, [y])
</span><a href="GHC.Utils.Monad.html#mapAccumLM"><span class="hs-identifier hs-var">mapAccumLM</span></a></span><span> </span><span class="annot"><span class="annottext">[Demand] -&gt; CoreExprWithFVs -&gt; UniqSM ([Demand], LevelledExpr)
</span><a href="#local-6989586621680962738"><span class="hs-identifier hs-var">lvl_arg</span></a></span><span> </span><span class="annot"><span class="annottext">[Demand]
</span><a href="#local-6989586621680962737"><span class="hs-identifier hs-var">stricts</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExprWithFVs]
</span><a href="#local-6989586621680962751"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-435"></span><span>            </span><span class="hs-comment">-- Take account of argument strictness; see</span><span>
</span><span id="line-436"></span><span>            </span><span class="hs-comment">-- Note [Floating to the top]</span><span>
</span><span id="line-437"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">LevelledExpr -&gt; LvlM LevelledExpr
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(LevelledExpr -&gt; LevelledExpr -&gt; LevelledExpr)
-&gt; LevelledExpr -&gt; [LevelledExpr] -&gt; LevelledExpr
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">LevelledExpr -&gt; LevelledExpr -&gt; LevelledExpr
forall b. Expr b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#App"><span class="hs-identifier hs-var">App</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; Id -&gt; LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lookupVar"><span class="hs-identifier hs-var">lookupVar</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962754"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962752"><span class="hs-identifier hs-var">fn</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[LevelledExpr]
</span><a href="#local-6989586621680962739"><span class="hs-identifier hs-var">args'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-438"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-439"></span><span>    </span><span id="local-6989586621680962745"><span class="annot"><span class="annottext">n_val_args :: Int
</span><a href="#local-6989586621680962745"><span class="hs-identifier hs-var hs-var">n_val_args</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CoreExprWithFVs -&gt; Bool) -&gt; [CoreExprWithFVs] -&gt; Int
forall a. (a -&gt; Bool) -&gt; [a] -&gt; Int
</span><a href="GHC.Utils.Misc.html#count"><span class="hs-identifier hs-var">count</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Expr Id -&gt; Bool
forall b. Expr b -&gt; Bool
</span><a href="GHC.Core.html#isValArg"><span class="hs-identifier hs-var">isValArg</span></a></span><span> </span><span class="annot"><span class="annottext">(Expr Id -&gt; Bool)
-&gt; (CoreExprWithFVs -&gt; Expr Id) -&gt; CoreExprWithFVs -&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs -&gt; Expr Id
forall bndr annot. AnnExpr bndr annot -&gt; Expr bndr
</span><a href="GHC.Core.html#deAnnotate"><span class="hs-identifier hs-var">deAnnotate</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CoreExprWithFVs]
</span><a href="#local-6989586621680962751"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-440"></span><span>    </span><span id="local-6989586621680962746"><span class="annot"><span class="annottext">arity :: Int
</span><a href="#local-6989586621680962746"><span class="hs-identifier hs-var hs-var">arity</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Int
</span><a href="GHC.Types.Id.html#idArity"><span class="hs-identifier hs-var">idArity</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962752"><span class="hs-identifier hs-var">fn</span></a></span><span>
</span><span id="line-441"></span><span>
</span><span id="line-442"></span><span>    </span><span class="annot"><a href="#local-6989586621680962737"><span class="hs-identifier hs-type">stricts</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Demand.html#Demand"><span class="hs-identifier hs-type">Demand</span></a></span><span class="hs-special">]</span><span>   </span><span class="hs-comment">-- True for strict /value/ arguments</span><span>
</span><span id="line-443"></span><span>    </span><span id="local-6989586621680962737"><span class="annot"><span class="annottext">stricts :: [Demand]
</span><a href="#local-6989586621680962737"><span class="hs-identifier hs-var hs-var">stricts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">StrictSig -&gt; ([Demand], Divergence)
</span><a href="GHC.Types.Demand.html#splitStrictSig"><span class="hs-identifier hs-var">splitStrictSig</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; StrictSig
</span><a href="GHC.Types.Id.html#idStrictness"><span class="hs-identifier hs-var">idStrictness</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962752"><span class="hs-identifier hs-var">fn</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-444"></span><span>                </span><span class="hs-special">(</span><span id="local-6989586621680962730"><span class="annot"><span class="annottext">[Demand]
</span><a href="#local-6989586621680962730"><span class="hs-identifier hs-var">arg_ds</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Divergence
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[Demand]
</span><a href="#local-6989586621680962730"><span class="hs-identifier hs-var">arg_ds</span></a></span><span> </span><span class="annot"><span class="annottext">[Demand] -&gt; Int -&gt; Bool
forall a. [a] -&gt; Int -&gt; Bool
</span><a href="GHC.Utils.Misc.html#lengthExceeds"><span class="hs-operator hs-var">`lengthExceeds`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962745"><span class="hs-identifier hs-var">n_val_args</span></a></span><span>
</span><span id="line-445"></span><span>                            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-446"></span><span>                            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-447"></span><span>                            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[Demand]
</span><a href="#local-6989586621680962730"><span class="hs-identifier hs-var">arg_ds</span></a></span><span>
</span><span id="line-448"></span><span>
</span><span id="line-449"></span><span>    </span><span class="hs-comment">-- Separate out the PAP that we are floating from the extra</span><span>
</span><span id="line-450"></span><span>    </span><span class="hs-comment">-- arguments, by traversing the spine until we have collected</span><span>
</span><span id="line-451"></span><span>    </span><span class="hs-comment">-- (n_val_args - arity) value arguments.</span><span>
</span><span id="line-452"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680962740"><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962740"><span class="hs-identifier hs-var">lapp</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962742"><span class="annot"><span class="annottext">[CoreExprWithFVs]
</span><a href="#local-6989586621680962742"><span class="hs-identifier hs-var">rargs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
-&gt; CoreExprWithFVs
-&gt; [CoreExprWithFVs]
-&gt; (CoreExprWithFVs, [CoreExprWithFVs])
forall {t} {b} {annot}.
(Eq t, Num t) =&gt;
t
-&gt; AnnExpr b annot
-&gt; [AnnExpr b annot]
-&gt; (AnnExpr b annot, [AnnExpr b annot])
</span><a href="#local-6989586621680962725"><span class="hs-identifier hs-var">left</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962745"><span class="hs-identifier hs-var">n_val_args</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962746"><span class="hs-identifier hs-var">arity</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962753"><span class="hs-identifier hs-var">orig_expr</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-453"></span><span>
</span><span id="line-454"></span><span>    </span><span id="local-6989586621680962725"><span class="annot"><span class="annottext">left :: t
-&gt; AnnExpr b annot
-&gt; [AnnExpr b annot]
-&gt; (AnnExpr b annot, [AnnExpr b annot])
</span><a href="#local-6989586621680962725"><span class="hs-identifier hs-var hs-var">left</span></a></span></span><span> </span><span class="annot"><span class="annottext">t
</span><span class="hs-number">0</span></span><span> </span><span id="local-6989586621680962718"><span class="annot"><span class="annottext">AnnExpr b annot
</span><a href="#local-6989586621680962718"><span class="hs-identifier hs-var">e</span></a></span></span><span>               </span><span id="local-6989586621680962717"><span class="annot"><span class="annottext">[AnnExpr b annot]
</span><a href="#local-6989586621680962717"><span class="hs-identifier hs-var">rargs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AnnExpr b annot
</span><a href="#local-6989586621680962718"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[AnnExpr b annot]
</span><a href="#local-6989586621680962717"><span class="hs-identifier hs-var">rargs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-455"></span><span>    </span><span class="annot"><a href="#local-6989586621680962725"><span class="hs-identifier hs-var">left</span></a></span><span> </span><span id="local-6989586621680962716"><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621680962716"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">annot
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#AnnApp"><span class="hs-identifier hs-type">AnnApp</span></a></span><span> </span><span id="local-6989586621680962715"><span class="annot"><span class="annottext">AnnExpr b annot
</span><a href="#local-6989586621680962715"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621680962714"><span class="annot"><span class="annottext">AnnExpr b annot
</span><a href="#local-6989586621680962714"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680962713"><span class="annot"><span class="annottext">[AnnExpr b annot]
</span><a href="#local-6989586621680962713"><span class="hs-identifier hs-var">rargs</span></a></span></span><span>
</span><span id="line-456"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Expr b -&gt; Bool
forall b. Expr b -&gt; Bool
</span><a href="GHC.Core.html#isValArg"><span class="hs-identifier hs-var">isValArg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AnnExpr b annot -&gt; Expr b
forall bndr annot. AnnExpr bndr annot -&gt; Expr bndr
</span><a href="GHC.Core.html#deAnnotate"><span class="hs-identifier hs-var">deAnnotate</span></a></span><span> </span><span class="annot"><span class="annottext">AnnExpr b annot
</span><a href="#local-6989586621680962714"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">t
-&gt; AnnExpr b annot
-&gt; [AnnExpr b annot]
-&gt; (AnnExpr b annot, [AnnExpr b annot])
</span><a href="#local-6989586621680962725"><span class="hs-identifier hs-var">left</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621680962716"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">t -&gt; t -&gt; t
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">t
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">AnnExpr b annot
</span><a href="#local-6989586621680962715"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AnnExpr b annot
</span><a href="#local-6989586621680962714"><span class="hs-identifier hs-var">a</span></a></span><span class="annot"><span class="annottext">AnnExpr b annot -&gt; [AnnExpr b annot] -&gt; [AnnExpr b annot]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[AnnExpr b annot]
</span><a href="#local-6989586621680962713"><span class="hs-identifier hs-var">rargs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-457"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>               </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">t
-&gt; AnnExpr b annot
-&gt; [AnnExpr b annot]
-&gt; (AnnExpr b annot, [AnnExpr b annot])
</span><a href="#local-6989586621680962725"><span class="hs-identifier hs-var">left</span></a></span><span> </span><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621680962716"><span class="hs-identifier hs-var">n</span></a></span><span>     </span><span class="annot"><span class="annottext">AnnExpr b annot
</span><a href="#local-6989586621680962715"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AnnExpr b annot
</span><a href="#local-6989586621680962714"><span class="hs-identifier hs-var">a</span></a></span><span class="annot"><span class="annottext">AnnExpr b annot -&gt; [AnnExpr b annot] -&gt; [AnnExpr b annot]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[AnnExpr b annot]
</span><a href="#local-6989586621680962713"><span class="hs-identifier hs-var">rargs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-458"></span><span>    </span><span class="annot"><a href="#local-6989586621680962725"><span class="hs-identifier hs-var">left</span></a></span><span> </span><span class="annot"><span class="annottext">t
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">AnnExpr b annot
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">[AnnExpr b annot]
</span><span class="hs-identifier">_</span></span><span>                   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; (AnnExpr b annot, [AnnExpr b annot])
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#panic"><span class="hs-identifier hs-var">panic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;GHC.Core.Opt.SetLevels.lvlExpr.left&quot;</span></span><span>
</span><span id="line-459"></span><span>
</span><span id="line-460"></span><span>    </span><span class="annot"><a href="#local-6989586621680962711"><span class="hs-identifier hs-type">is_val_arg</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.FVs.html#CoreExprWithFVs"><span class="hs-identifier hs-type">CoreExprWithFVs</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-461"></span><span>    </span><span id="local-6989586621680962711"><span class="annot"><span class="annottext">is_val_arg :: CoreExprWithFVs -&gt; Bool
</span><a href="#local-6989586621680962711"><span class="hs-identifier hs-var hs-var">is_val_arg</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FVAnn
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#AnnType"><span class="hs-identifier hs-type">AnnType</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-462"></span><span>    </span><span class="annot"><a href="#local-6989586621680962711"><span class="hs-identifier hs-var">is_val_arg</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><span class="hs-identifier">_</span></span><span>               </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-463"></span><span>
</span><span id="line-464"></span><span>    </span><span class="annot"><a href="#local-6989586621680962738"><span class="hs-identifier hs-type">lvl_arg</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Demand.html#Demand"><span class="hs-identifier hs-type">Demand</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.FVs.html#CoreExprWithFVs"><span class="hs-identifier hs-type">CoreExprWithFVs</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LvlM"><span class="hs-identifier hs-type">LvlM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Demand.html#Demand"><span class="hs-identifier hs-type">Demand</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelledExpr"><span class="hs-identifier hs-type">LevelledExpr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-465"></span><span>    </span><span id="local-6989586621680962738"><span class="annot"><span class="annottext">lvl_arg :: [Demand] -&gt; CoreExprWithFVs -&gt; UniqSM ([Demand], LevelledExpr)
</span><a href="#local-6989586621680962738"><span class="hs-identifier hs-var hs-var">lvl_arg</span></a></span></span><span> </span><span id="local-6989586621680962710"><span class="annot"><span class="annottext">[Demand]
</span><a href="#local-6989586621680962710"><span class="hs-identifier hs-var">strs</span></a></span></span><span> </span><span id="local-6989586621680962709"><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962709"><span class="hs-identifier hs-var">arg</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680962708"><span class="annot"><span class="annottext">Demand
</span><a href="#local-6989586621680962708"><span class="hs-identifier hs-var">str1</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680962707"><span class="annot"><span class="annottext">[Demand]
</span><a href="#local-6989586621680962707"><span class="hs-identifier hs-var">strs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Demand]
</span><a href="#local-6989586621680962710"><span class="hs-identifier hs-var">strs</span></a></span><span>
</span><span id="line-466"></span><span>                     </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs -&gt; Bool
</span><a href="#local-6989586621680962711"><span class="hs-identifier hs-var">is_val_arg</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962709"><span class="hs-identifier hs-var">arg</span></a></span><span>
</span><span id="line-467"></span><span>                     </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680962706"><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962706"><span class="hs-identifier hs-var">arg'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Bool -&gt; CoreExprWithFVs -&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlMFE"><span class="hs-identifier hs-var">lvlMFE</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962754"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Demand -&gt; Bool
forall s u. JointDmd (Str s) (Use u) -&gt; Bool
</span><a href="GHC.Types.Demand.html#isStrictDmd"><span class="hs-identifier hs-var">isStrictDmd</span></a></span><span> </span><span class="annot"><span class="annottext">Demand
</span><a href="#local-6989586621680962708"><span class="hs-identifier hs-var">str1</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962709"><span class="hs-identifier hs-var">arg</span></a></span><span>
</span><span id="line-468"></span><span>                          </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">([Demand], LevelledExpr) -&gt; UniqSM ([Demand], LevelledExpr)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Demand]
</span><a href="#local-6989586621680962707"><span class="hs-identifier hs-var">strs'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962706"><span class="hs-identifier hs-var">arg'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-469"></span><span>                     </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-470"></span><span>                     </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680962704"><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962704"><span class="hs-identifier hs-var">arg'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Bool -&gt; CoreExprWithFVs -&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlMFE"><span class="hs-identifier hs-var">lvlMFE</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962754"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962709"><span class="hs-identifier hs-var">arg</span></a></span><span>
</span><span id="line-471"></span><span>                          </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">([Demand], LevelledExpr) -&gt; UniqSM ([Demand], LevelledExpr)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Demand]
</span><a href="#local-6989586621680962710"><span class="hs-identifier hs-var">strs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962704"><span class="hs-identifier hs-var">arg'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-472"></span><span>
</span><span id="line-473"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#lvlApp"><span class="hs-identifier hs-var">lvlApp</span></a></span><span> </span><span id="local-6989586621680962703"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962703"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680962702"><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962702"><span class="hs-identifier hs-var">fun</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962701"><span class="annot"><span class="annottext">[CoreExprWithFVs]
</span><a href="#local-6989586621680962701"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-474"></span><span>  </span><span class="hs-glyph">=</span><span>  </span><span class="hs-comment">-- No PAPs that we can float: just carry on with the</span><span>
</span><span id="line-475"></span><span>     </span><span class="hs-comment">-- arguments and the function.</span><span>
</span><span id="line-476"></span><span>     </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680962700"><span class="annot"><span class="annottext">[LevelledExpr]
</span><a href="#local-6989586621680962700"><span class="hs-identifier hs-var">args'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(CoreExprWithFVs -&gt; LvlM LevelledExpr)
-&gt; [CoreExprWithFVs] -&gt; UniqSM [LevelledExpr]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; Bool -&gt; CoreExprWithFVs -&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlNonTailMFE"><span class="hs-identifier hs-var">lvlNonTailMFE</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962703"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CoreExprWithFVs]
</span><a href="#local-6989586621680962701"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-477"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621680962699"><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962699"><span class="hs-identifier hs-var">fun'</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; CoreExprWithFVs -&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlNonTailExpr"><span class="hs-identifier hs-var">lvlNonTailExpr</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962703"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962702"><span class="hs-identifier hs-var">fun</span></a></span><span>
</span><span id="line-478"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">LevelledExpr -&gt; LvlM LevelledExpr
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(LevelledExpr -&gt; LevelledExpr -&gt; LevelledExpr)
-&gt; LevelledExpr -&gt; [LevelledExpr] -&gt; LevelledExpr
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">LevelledExpr -&gt; LevelledExpr -&gt; LevelledExpr
forall b. Expr b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#App"><span class="hs-identifier hs-var">App</span></a></span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962699"><span class="hs-identifier hs-var">fun'</span></a></span><span> </span><span class="annot"><span class="annottext">[LevelledExpr]
</span><a href="#local-6989586621680962700"><span class="hs-identifier hs-var">args'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-479"></span><span>
</span><span id="line-480"></span><span class="hs-comment">-------------------------------------------</span><span>
</span><span id="line-481"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#lvlCase"><span class="hs-identifier hs-type">lvlCase</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span>             </span><span class="hs-comment">-- Level of in-scope names/tyvars</span><span>
</span><span id="line-482"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#DVarSet"><span class="hs-identifier hs-type">DVarSet</span></a></span><span>              </span><span class="hs-comment">-- Free vars of input scrutinee</span><span>
</span><span id="line-483"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelledExpr"><span class="hs-identifier hs-type">LevelledExpr</span></a></span><span>         </span><span class="hs-comment">-- Processed scrutinee</span><span>
</span><span id="line-484"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>           </span><span class="hs-comment">-- Case binder and result type</span><span>
</span><span id="line-485"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.FVs.html#CoreAltWithFVs"><span class="hs-identifier hs-type">CoreAltWithFVs</span></a></span><span class="hs-special">]</span><span>     </span><span class="hs-comment">-- Input alternatives</span><span>
</span><span id="line-486"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LvlM"><span class="hs-identifier hs-type">LvlM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelledExpr"><span class="hs-identifier hs-type">LevelledExpr</span></a></span><span>    </span><span class="hs-comment">-- Result expression</span><span>
</span><span id="line-487"></span><span id="lvlCase"><span class="annot"><span class="annottext">lvlCase :: LevelEnv
-&gt; FVAnn
-&gt; LevelledExpr
-&gt; Id
-&gt; Type
-&gt; [AnnAlt Id FVAnn]
-&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlCase"><span class="hs-identifier hs-var hs-var">lvlCase</span></a></span></span><span> </span><span id="local-6989586621680962696"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962696"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680962695"><span class="annot"><span class="annottext">FVAnn
</span><a href="#local-6989586621680962695"><span class="hs-identifier hs-var">scrut_fvs</span></a></span></span><span> </span><span id="local-6989586621680962694"><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962694"><span class="hs-identifier hs-var">scrut'</span></a></span></span><span> </span><span id="local-6989586621680962693"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962693"><span class="hs-identifier hs-var">case_bndr</span></a></span></span><span> </span><span id="local-6989586621680962692"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680962692"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621680962691"><span class="annot"><span class="annottext">[AnnAlt Id FVAnn]
</span><a href="#local-6989586621680962691"><span class="hs-identifier hs-var">alts</span></a></span></span><span>
</span><span id="line-488"></span><span>  </span><span class="hs-comment">-- See Note [Floating single-alternative cases]</span><span>
</span><span id="line-489"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span id="local-6989586621680962690"><span class="annot"><span class="annottext">con :: AltCon
</span><a href="#local-6989586621680962690"><span class="hs-identifier hs-var">con</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#DataAlt"><span class="hs-identifier hs-type">DataAlt</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962688"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962688"><span class="hs-identifier hs-var">bs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962687"><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962687"><span class="hs-identifier hs-var">body</span></a></span></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[AnnAlt Id FVAnn]
</span><a href="#local-6989586621680962691"><span class="hs-identifier hs-var">alts</span></a></span><span>
</span><span id="line-490"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Expr Id -&gt; Bool
</span><a href="GHC.Core.Utils.html#exprIsHNF"><span class="hs-identifier hs-var">exprIsHNF</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelledExpr -&gt; Expr Id
forall t. TaggedExpr t -&gt; Expr Id
</span><a href="GHC.Core.html#deTagExpr"><span class="hs-identifier hs-var">deTagExpr</span></a></span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962694"><span class="hs-identifier hs-var">scrut'</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- See Note [Check the output scrutinee for exprIsHNF]</span><span>
</span><span id="line-491"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Level -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#isTopLvl"><span class="hs-identifier hs-var">isTopLvl</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962684"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span class="hs-special">)</span><span>       </span><span class="hs-comment">-- Can't have top-level cases</span><span>
</span><span id="line-492"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#floatTopLvlOnly"><span class="hs-identifier hs-var">floatTopLvlOnly</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962696"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span>     </span><span class="hs-comment">-- Can float anywhere</span><span>
</span><span id="line-493"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Core.Type.html#Many"><span class="hs-identifier hs-var">Many</span></a></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Types.Id.html#idMult"><span class="hs-identifier hs-var">idMult</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962693"><span class="hs-identifier hs-var">case_bndr</span></a></span><span>     </span><span class="hs-comment">-- See Note [Floating linear case]</span><span>
</span><span id="line-494"></span><span>  </span><span class="hs-glyph">=</span><span>     </span><span class="hs-comment">-- Always float the case if possible</span><span>
</span><span id="line-495"></span><span>        </span><span class="hs-comment">-- Unlike lets we don't insist that it escapes a value lambda</span><span>
</span><span id="line-496"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680962681"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962681"><span class="hs-identifier hs-var">env1</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680962680"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962680"><span class="hs-identifier hs-var">case_bndr'</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680962679"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962679"><span class="hs-identifier hs-var">bs'</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Level -&gt; [Id] -&gt; LvlM (LevelEnv, [Id])
</span><a href="GHC.Core.Opt.SetLevels.html#cloneCaseBndrs"><span class="hs-identifier hs-var">cloneCaseBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962696"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962684"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962693"><span class="hs-identifier hs-var">case_bndr</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; [Id] -&gt; [Id]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962688"><span class="hs-identifier hs-var">bs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-497"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680962677"><span class="annot"><span class="annottext">rhs_env :: LevelEnv
</span><a href="#local-6989586621680962677"><span class="hs-identifier hs-var hs-var">rhs_env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Id -&gt; LevelledExpr -&gt; LevelEnv
</span><a href="GHC.Core.Opt.SetLevels.html#extendCaseBndrEnv"><span class="hs-identifier hs-var">extendCaseBndrEnv</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962681"><span class="hs-identifier hs-var">env1</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962693"><span class="hs-identifier hs-var">case_bndr</span></a></span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962694"><span class="hs-identifier hs-var">scrut'</span></a></span><span>
</span><span id="line-498"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621680962675"><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962675"><span class="hs-identifier hs-var">body'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Bool -&gt; CoreExprWithFVs -&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlMFE"><span class="hs-identifier hs-var">lvlMFE</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962677"><span class="hs-identifier hs-var">rhs_env</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962687"><span class="hs-identifier hs-var">body</span></a></span><span>
</span><span id="line-499"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680962674"><span class="annot"><span class="annottext">alt' :: (AltCon, [LevelledBndr], LevelledExpr)
</span><a href="#local-6989586621680962674"><span class="hs-identifier hs-var hs-var">alt'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AltCon
</span><a href="#local-6989586621680962690"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; LevelledBndr) -&gt; [Id] -&gt; [LevelledBndr]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Level -&gt; Id -&gt; LevelledBndr
</span><a href="GHC.Core.Opt.SetLevels.html#stayPut"><span class="hs-identifier hs-var">stayPut</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962684"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962679"><span class="hs-identifier hs-var">bs'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962675"><span class="hs-identifier hs-var">body'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-500"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">LevelledExpr -&gt; LvlM LevelledExpr
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelledExpr
-&gt; LevelledBndr
-&gt; Type
-&gt; [(AltCon, [LevelledBndr], LevelledExpr)]
-&gt; LevelledExpr
forall b. Expr b -&gt; b -&gt; Type -&gt; [Alt b] -&gt; Expr b
</span><a href="GHC.Core.html#Case"><span class="hs-identifier hs-var">Case</span></a></span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962694"><span class="hs-identifier hs-var">scrut'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; FloatSpec -&gt; LevelledBndr
forall t. Id -&gt; t -&gt; TaggedBndr t
</span><a href="GHC.Core.html#TB"><span class="hs-identifier hs-var">TB</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962680"><span class="hs-identifier hs-var">case_bndr'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Level -&gt; FloatSpec
</span><a href="GHC.Core.Opt.SetLevels.html#FloatMe"><span class="hs-identifier hs-var">FloatMe</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962684"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680962670"><span class="hs-identifier hs-var">ty'</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">(AltCon, [LevelledBndr], LevelledExpr)
</span><a href="#local-6989586621680962674"><span class="hs-identifier hs-var">alt'</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-501"></span><span>
</span><span id="line-502"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>     </span><span class="hs-comment">-- Stays put</span><span>
</span><span id="line-503"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680962669"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962669"><span class="hs-identifier hs-var">alts_env1</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span id="local-6989586621680962668"><span class="annot"><span class="annottext">LevelledBndr
</span><a href="#local-6989586621680962668"><span class="hs-identifier hs-var">case_bndr'</span></a></span></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RecFlag -&gt; LevelEnv -&gt; Level -&gt; [Id] -&gt; (LevelEnv, [LevelledBndr])
</span><a href="GHC.Core.Opt.SetLevels.html#substAndLvlBndrs"><span class="hs-identifier hs-var">substAndLvlBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="GHC.Types.Basic.html#NonRecursive"><span class="hs-identifier hs-var">NonRecursive</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962696"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962667"><span class="hs-identifier hs-var">incd_lvl</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962693"><span class="hs-identifier hs-var">case_bndr</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-504"></span><span>             </span><span id="local-6989586621680962666"><span class="annot"><span class="annottext">alts_env :: LevelEnv
</span><a href="#local-6989586621680962666"><span class="hs-identifier hs-var hs-var">alts_env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Id -&gt; LevelledExpr -&gt; LevelEnv
</span><a href="GHC.Core.Opt.SetLevels.html#extendCaseBndrEnv"><span class="hs-identifier hs-var">extendCaseBndrEnv</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962669"><span class="hs-identifier hs-var">alts_env1</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962693"><span class="hs-identifier hs-var">case_bndr</span></a></span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962694"><span class="hs-identifier hs-var">scrut'</span></a></span><span>
</span><span id="line-505"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621680962665"><span class="annot"><span class="annottext">[(AltCon, [LevelledBndr], LevelledExpr)]
</span><a href="#local-6989586621680962665"><span class="hs-identifier hs-var">alts'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(AnnAlt Id FVAnn -&gt; UniqSM (AltCon, [LevelledBndr], LevelledExpr))
-&gt; [AnnAlt Id FVAnn]
-&gt; UniqSM [(AltCon, [LevelledBndr], LevelledExpr)]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv
-&gt; AnnAlt Id FVAnn -&gt; UniqSM (AltCon, [LevelledBndr], LevelledExpr)
forall {a}.
LevelEnv
-&gt; (a, [Id], CoreExprWithFVs)
-&gt; UniqSM (a, [LevelledBndr], LevelledExpr)
</span><a href="#local-6989586621680962664"><span class="hs-identifier hs-var">lvl_alt</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962666"><span class="hs-identifier hs-var">alts_env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[AnnAlt Id FVAnn]
</span><a href="#local-6989586621680962691"><span class="hs-identifier hs-var">alts</span></a></span><span>
</span><span id="line-506"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">LevelledExpr -&gt; LvlM LevelledExpr
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelledExpr
-&gt; LevelledBndr
-&gt; Type
-&gt; [(AltCon, [LevelledBndr], LevelledExpr)]
-&gt; LevelledExpr
forall b. Expr b -&gt; b -&gt; Type -&gt; [Alt b] -&gt; Expr b
</span><a href="GHC.Core.html#Case"><span class="hs-identifier hs-var">Case</span></a></span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962694"><span class="hs-identifier hs-var">scrut'</span></a></span><span> </span><span class="annot"><span class="annottext">LevelledBndr
</span><a href="#local-6989586621680962668"><span class="hs-identifier hs-var">case_bndr'</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680962670"><span class="hs-identifier hs-var">ty'</span></a></span><span> </span><span class="annot"><span class="annottext">[(AltCon, [LevelledBndr], LevelledExpr)]
</span><a href="#local-6989586621680962665"><span class="hs-identifier hs-var">alts'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-507"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-508"></span><span>    </span><span id="local-6989586621680962670"><span class="annot"><span class="annottext">ty' :: Type
</span><a href="#local-6989586621680962670"><span class="hs-identifier hs-var hs-var">ty'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; Type -&gt; Type
</span><a href="GHC.Core.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; Subst
</span><a href="GHC.Core.Opt.SetLevels.html#le_subst"><span class="hs-identifier hs-var hs-var">le_subst</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962696"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680962692"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-509"></span><span>
</span><span id="line-510"></span><span>    </span><span id="local-6989586621680962667"><span class="annot"><span class="annottext">incd_lvl :: Level
</span><a href="#local-6989586621680962667"><span class="hs-identifier hs-var hs-var">incd_lvl</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#incMinorLvl"><span class="hs-identifier hs-var">incMinorLvl</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#le_ctxt_lvl"><span class="hs-identifier hs-var hs-var">le_ctxt_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962696"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-511"></span><span>    </span><span id="local-6989586621680962684"><span class="annot"><span class="annottext">dest_lvl :: Level
</span><a href="#local-6989586621680962684"><span class="hs-identifier hs-var hs-var">dest_lvl</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Bool) -&gt; LevelEnv -&gt; FVAnn -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#maxFvLevel"><span class="hs-identifier hs-var">maxFvLevel</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Id -&gt; Bool
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962696"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">FVAnn
</span><a href="#local-6989586621680962695"><span class="hs-identifier hs-var">scrut_fvs</span></a></span><span>
</span><span id="line-512"></span><span>            </span><span class="hs-comment">-- Don't abstract over type variables, hence const True</span><span>
</span><span id="line-513"></span><span>
</span><span id="line-514"></span><span>    </span><span id="local-6989586621680962664"><span class="annot"><span class="annottext">lvl_alt :: LevelEnv
-&gt; (a, [Id], CoreExprWithFVs)
-&gt; UniqSM (a, [LevelledBndr], LevelledExpr)
</span><a href="#local-6989586621680962664"><span class="hs-identifier hs-var hs-var">lvl_alt</span></a></span></span><span> </span><span id="local-6989586621680962659"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962659"><span class="hs-identifier hs-var">alts_env</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680962658"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680962658"><span class="hs-identifier hs-var">con</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962657"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962657"><span class="hs-identifier hs-var">bs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962656"><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962656"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-515"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680962655"><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962655"><span class="hs-identifier hs-var">rhs'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Bool -&gt; CoreExprWithFVs -&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlMFE"><span class="hs-identifier hs-var">lvlMFE</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962654"><span class="hs-identifier hs-var">new_env</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962656"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-516"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(a, [LevelledBndr], LevelledExpr)
-&gt; UniqSM (a, [LevelledBndr], LevelledExpr)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680962658"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[LevelledBndr]
</span><a href="#local-6989586621680962653"><span class="hs-identifier hs-var">bs'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962655"><span class="hs-identifier hs-var">rhs'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-517"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-518"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621680962654"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962654"><span class="hs-identifier hs-var">new_env</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962653"><span class="annot"><span class="annottext">[LevelledBndr]
</span><a href="#local-6989586621680962653"><span class="hs-identifier hs-var">bs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RecFlag -&gt; LevelEnv -&gt; Level -&gt; [Id] -&gt; (LevelEnv, [LevelledBndr])
</span><a href="GHC.Core.Opt.SetLevels.html#substAndLvlBndrs"><span class="hs-identifier hs-var">substAndLvlBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="GHC.Types.Basic.html#NonRecursive"><span class="hs-identifier hs-var">NonRecursive</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962659"><span class="hs-identifier hs-var">alts_env</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962667"><span class="hs-identifier hs-var">incd_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962657"><span class="hs-identifier hs-var">bs</span></a></span><span>
</span><span id="line-519"></span><span>
</span><span id="line-520"></span><span class="hs-comment">{- Note [Floating single-alternative cases]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider this:
  data T a = MkT !a
  f :: T Int -&gt; blah
  f x vs = case x of { MkT y -&gt;
             let f vs = ...(case y of I# w -&gt; e)...f..
             in f vs

Here we can float the (case y ...) out, because y is sure
to be evaluated, to give
  f x vs = case x of { MkT y -&gt;
           case y of I# w -&gt;
             let f vs = ...(e)...f..
             in f vs

That saves unboxing it every time round the loop.  It's important in
some DPH stuff where we really want to avoid that repeated unboxing in
the inner loop.

Things to note:

 * The test we perform is exprIsHNF, and /not/ exprOkForSpeculation.

     - exrpIsHNF catches the key case of an evaluated variable

     - exprOkForSpeculation is /false/ of an evaluated variable;
       See Note [exprOkForSpeculation and evaluated variables] in GHC.Core.Utils
       So we'd actually miss the key case!

     - Nothing is gained from the extra generality of exprOkForSpeculation
       since we only consider floating a case whose single alternative
       is a DataAlt   K a b -&gt; rhs

 * We can't float a case to top level

 * It's worth doing this float even if we don't float
   the case outside a value lambda.  Example
     case x of {
       MkT y -&gt; (case y of I# w2 -&gt; ..., case y of I# w2 -&gt; ...)
   If we floated the cases out we could eliminate one of them.

 * We only do this with a single-alternative case


Note [Floating linear case]
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Linear case can't be floated past case branches:
    case u of { p1 -&gt; case[1] v of { C x -&gt; ...x...}; p2 -&gt; ... }
Is well typed, but
    case[1] v of { C x -&gt; case u of { p1 -&gt; ...x...; p2 -&gt; ... }}
Will not be, because of how `x` is used in one alternative but not the other.

It is not easy to float this linear cases precisely, so, instead, we elect, for
the moment, to simply not float linear case.


Note [Setting levels when floating single-alternative cases]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Handling level-setting when floating a single-alternative case binding
is a bit subtle, as evidenced by #16978.  In particular, we must keep
in mind that we are merely moving the case and its binders, not the
body. For example, suppose 'a' is known to be evaluated and we have

  \z -&gt; case a of
          (x,_) -&gt; &lt;body involving x and z&gt;

After floating we may have:

  case a of
    (x,_) -&gt; \z -&gt; &lt;body involving x and z&gt;
      {- some expression involving x and z -}

When analysing &lt;body involving...&gt; we want to use the /ambient/ level,
and /not/ the destination level of the 'case a of (x,-) -&gt;' binding.

#16978 was caused by us setting the context level to the destination
level of `x` when analysing &lt;body&gt;. This led us to conclude that we
needed to quantify over some of its free variables (e.g. z), resulting
in shadowing and very confusing Core Lint failures.


Note [Check the output scrutinee for exprIsHNF]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider this:
  case x of y {
    A -&gt; ....(case y of alts)....
  }

Because of the binder-swap, the inner case will get substituted to
(case x of ..).  So when testing whether the scrutinee is in HNF we
must be careful to test the *result* scrutinee ('x' in this case), not
the *input* one 'y'.  The latter *is* in HNF here (because y is
evaluated), but the former is not -- and indeed we can't float the
inner case out, at least not unless x is also evaluated at its binding
site.  See #5453.

That's why we apply exprIsHNF to scrut' and not to scrut.

See Note [Floating single-alternative cases] for why
we use exprIsHNF in the first place.
-}</span><span>
</span><span id="line-622"></span><span>
</span><span id="line-623"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#lvlNonTailMFE"><span class="hs-identifier hs-type">lvlNonTailMFE</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span>             </span><span class="hs-comment">-- Level of in-scope names/tyvars</span><span>
</span><span id="line-624"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>                 </span><span class="hs-comment">-- True &lt;=&gt; strict context [body of case</span><span>
</span><span id="line-625"></span><span>                                      </span><span class="hs-comment">--   or let]</span><span>
</span><span id="line-626"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.FVs.html#CoreExprWithFVs"><span class="hs-identifier hs-type">CoreExprWithFVs</span></a></span><span>      </span><span class="hs-comment">-- input expression</span><span>
</span><span id="line-627"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LvlM"><span class="hs-identifier hs-type">LvlM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelledExpr"><span class="hs-identifier hs-type">LevelledExpr</span></a></span><span>    </span><span class="hs-comment">-- Result expression</span><span>
</span><span id="line-628"></span><span id="lvlNonTailMFE"><span class="annot"><span class="annottext">lvlNonTailMFE :: LevelEnv -&gt; Bool -&gt; CoreExprWithFVs -&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlNonTailMFE"><span class="hs-identifier hs-var hs-var">lvlNonTailMFE</span></a></span></span><span> </span><span id="local-6989586621680962652"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962652"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680962651"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962651"><span class="hs-identifier hs-var">strict_ctxt</span></a></span></span><span> </span><span id="local-6989586621680962650"><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962650"><span class="hs-identifier hs-var">ann_expr</span></a></span></span><span>
</span><span id="line-629"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Bool -&gt; CoreExprWithFVs -&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlMFE"><span class="hs-identifier hs-var">lvlMFE</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; LevelEnv
</span><a href="GHC.Core.Opt.SetLevels.html#placeJoinCeiling"><span class="hs-identifier hs-var">placeJoinCeiling</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962652"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962651"><span class="hs-identifier hs-var">strict_ctxt</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962650"><span class="hs-identifier hs-var">ann_expr</span></a></span><span>
</span><span id="line-630"></span><span>
</span><span id="line-631"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#lvlMFE"><span class="hs-identifier hs-type">lvlMFE</span></a></span><span> </span><span class="hs-glyph">::</span><span>  </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span>             </span><span class="hs-comment">-- Level of in-scope names/tyvars</span><span>
</span><span id="line-632"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>                 </span><span class="hs-comment">-- True &lt;=&gt; strict context [body of case or let]</span><span>
</span><span id="line-633"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.FVs.html#CoreExprWithFVs"><span class="hs-identifier hs-type">CoreExprWithFVs</span></a></span><span>      </span><span class="hs-comment">-- input expression</span><span>
</span><span id="line-634"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LvlM"><span class="hs-identifier hs-type">LvlM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelledExpr"><span class="hs-identifier hs-type">LevelledExpr</span></a></span><span>    </span><span class="hs-comment">-- Result expression</span><span>
</span><span id="line-635"></span><span class="hs-comment">-- lvlMFE is just like lvlExpr, except that it might let-bind</span><span>
</span><span id="line-636"></span><span class="hs-comment">-- the expression, so that it can itself be floated.</span><span>
</span><span id="line-637"></span><span>
</span><span id="line-638"></span><span id="lvlMFE"><span class="annot"><span class="annottext">lvlMFE :: LevelEnv -&gt; Bool -&gt; CoreExprWithFVs -&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlMFE"><span class="hs-identifier hs-var hs-var">lvlMFE</span></a></span></span><span> </span><span id="local-6989586621680962649"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962649"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FVAnn
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#AnnType"><span class="hs-identifier hs-type">AnnType</span></a></span><span> </span><span id="local-6989586621680962648"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680962648"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-639"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelledExpr -&gt; LvlM LevelledExpr
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; LevelledExpr
forall b. Type -&gt; Expr b
</span><a href="GHC.Core.html#Type"><span class="hs-identifier hs-var">Type</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst -&gt; Type -&gt; Type
</span><a href="GHC.Core.Subst.html#substTy"><span class="hs-identifier hs-var">GHC.Core.Subst.substTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; Subst
</span><a href="GHC.Core.Opt.SetLevels.html#le_subst"><span class="hs-identifier hs-var hs-var">le_subst</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962649"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680962648"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-640"></span><span>
</span><span id="line-641"></span><span class="hs-comment">-- No point in floating out an expression wrapped in a coercion or note</span><span>
</span><span id="line-642"></span><span class="hs-comment">-- If we do we'll transform  lvl = e |&gt; co</span><span>
</span><span id="line-643"></span><span class="hs-comment">--                       to  lvl' = e; lvl = lvl' |&gt; co</span><span>
</span><span id="line-644"></span><span class="hs-comment">-- and then inline lvl.  Better just to float out the payload.</span><span>
</span><span id="line-645"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#lvlMFE"><span class="hs-identifier hs-var">lvlMFE</span></a></span><span> </span><span id="local-6989586621680962647"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962647"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680962646"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962646"><span class="hs-identifier hs-var">strict_ctxt</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FVAnn
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#AnnTick"><span class="hs-identifier hs-type">AnnTick</span></a></span><span> </span><span id="local-6989586621680962645"><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621680962645"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span id="local-6989586621680962644"><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962644"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-646"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680962643"><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962643"><span class="hs-identifier hs-var">e'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Bool -&gt; CoreExprWithFVs -&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlMFE"><span class="hs-identifier hs-var">lvlMFE</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962647"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962646"><span class="hs-identifier hs-var">strict_ctxt</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962644"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-647"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680962642"><span class="annot"><span class="annottext">t' :: Tickish Id
</span><a href="#local-6989586621680962642"><span class="hs-identifier hs-var hs-var">t'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; Tickish Id -&gt; Tickish Id
</span><a href="GHC.Core.Subst.html#substTickish"><span class="hs-identifier hs-var">substTickish</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; Subst
</span><a href="GHC.Core.Opt.SetLevels.html#le_subst"><span class="hs-identifier hs-var hs-var">le_subst</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962647"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621680962645"><span class="hs-identifier hs-var">t</span></a></span><span>
</span><span id="line-648"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">LevelledExpr -&gt; LvlM LevelledExpr
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tickish Id -&gt; LevelledExpr -&gt; LevelledExpr
forall b. Tickish Id -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Tick"><span class="hs-identifier hs-var">Tick</span></a></span><span> </span><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621680962642"><span class="hs-identifier hs-var">t'</span></a></span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962643"><span class="hs-identifier hs-var">e'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-649"></span><span>
</span><span id="line-650"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#lvlMFE"><span class="hs-identifier hs-var">lvlMFE</span></a></span><span> </span><span id="local-6989586621680962641"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962641"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680962640"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962640"><span class="hs-identifier hs-var">strict_ctxt</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FVAnn
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#AnnCast"><span class="hs-identifier hs-type">AnnCast</span></a></span><span> </span><span id="local-6989586621680962639"><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962639"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FVAnn
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962638"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680962638"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-651"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680962637"><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962637"><span class="hs-identifier hs-var">e'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Bool -&gt; CoreExprWithFVs -&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlMFE"><span class="hs-identifier hs-var">lvlMFE</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962641"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962640"><span class="hs-identifier hs-var">strict_ctxt</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962639"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-652"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">LevelledExpr -&gt; LvlM LevelledExpr
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelledExpr -&gt; Coercion -&gt; LevelledExpr
forall b. Expr b -&gt; Coercion -&gt; Expr b
</span><a href="GHC.Core.html#Cast"><span class="hs-identifier hs-var">Cast</span></a></span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962637"><span class="hs-identifier hs-var">e'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasCallStack =&gt; Subst -&gt; Coercion -&gt; Coercion
Subst -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Subst.html#substCo"><span class="hs-identifier hs-var">substCo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; Subst
</span><a href="GHC.Core.Opt.SetLevels.html#le_subst"><span class="hs-identifier hs-var hs-var">le_subst</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962641"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680962638"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-653"></span><span>
</span><span id="line-654"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#lvlMFE"><span class="hs-identifier hs-var">lvlMFE</span></a></span><span> </span><span id="local-6989586621680962636"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962636"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680962635"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962635"><span class="hs-identifier hs-var">strict_ctxt</span></a></span></span><span> </span><span id="local-6989586621680962634"><span class="annot"><span class="annottext">e :: CoreExprWithFVs
</span><a href="#local-6989586621680962634"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><span class="annottext">FVAnn
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#AnnCase"><span class="hs-identifier hs-type">AnnCase</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-655"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962635"><span class="hs-identifier hs-var">strict_ctxt</span></a></span><span>       </span><span class="hs-comment">-- Don't share cases in a strict context</span><span>
</span><span id="line-656"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; CoreExprWithFVs -&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlExpr"><span class="hs-identifier hs-var">lvlExpr</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962636"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962634"><span class="hs-identifier hs-var">e</span></a></span><span>     </span><span class="hs-comment">-- See Note [Case MFEs]</span><span>
</span><span id="line-657"></span><span>
</span><span id="line-658"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#lvlMFE"><span class="hs-identifier hs-var">lvlMFE</span></a></span><span> </span><span id="local-6989586621680962633"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962633"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680962632"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962632"><span class="hs-identifier hs-var">strict_ctxt</span></a></span></span><span> </span><span id="local-6989586621680962631"><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962631"><span class="hs-identifier hs-var">ann_expr</span></a></span></span><span>
</span><span id="line-659"></span><span>  </span><span class="hs-glyph">|</span><span>  </span><span class="annot"><span class="annottext">LevelEnv -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#floatTopLvlOnly"><span class="hs-identifier hs-var">floatTopLvlOnly</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962633"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Level -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#isTopLvl"><span class="hs-identifier hs-var">isTopLvl</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962630"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-660"></span><span>         </span><span class="hs-comment">-- Only floating to the top level is allowed.</span><span>
</span><span id="line-661"></span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; FVAnn -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#hasFreeJoin"><span class="hs-identifier hs-var">hasFreeJoin</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962633"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">FVAnn
</span><a href="#local-6989586621680962628"><span class="hs-identifier hs-var">fvs</span></a></span><span>   </span><span class="hs-comment">-- If there is a free join, don't float</span><span>
</span><span id="line-662"></span><span>                           </span><span class="hs-comment">-- See Note [Free join points]</span><span>
</span><span id="line-663"></span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Expr Id -&gt; Bool
</span><a href="GHC.Core.Utils.html#isExprLevPoly"><span class="hs-identifier hs-var">isExprLevPoly</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621680962627"><span class="hs-identifier hs-var">expr</span></a></span><span>
</span><span id="line-664"></span><span>         </span><span class="hs-comment">-- We can't let-bind levity polymorphic expressions</span><span>
</span><span id="line-665"></span><span>         </span><span class="hs-comment">-- See Note [Levity polymorphism invariants] in GHC.Core</span><span>
</span><span id="line-666"></span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Expr Id -&gt; [Id] -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#notWorthFloating"><span class="hs-identifier hs-var">notWorthFloating</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621680962627"><span class="hs-identifier hs-var">expr</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962625"><span class="hs-identifier hs-var">abs_vars</span></a></span><span>
</span><span id="line-667"></span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962624"><span class="hs-identifier hs-var">float_me</span></a></span><span>
</span><span id="line-668"></span><span>  </span><span class="hs-glyph">=</span><span>     </span><span class="hs-comment">-- Don't float it out</span><span>
</span><span id="line-669"></span><span>    </span><span class="annot"><span class="annottext">LevelEnv -&gt; CoreExprWithFVs -&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlExpr"><span class="hs-identifier hs-var">lvlExpr</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962633"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962631"><span class="hs-identifier hs-var">ann_expr</span></a></span><span>
</span><span id="line-670"></span><span>
</span><span id="line-671"></span><span>  </span><span class="hs-glyph">|</span><span>  </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962623"><span class="hs-identifier hs-var">float_is_new_lam</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Expr Id -&gt; Type -&gt; Bool
</span><a href="GHC.Core.Utils.html#exprIsTopLevelBindable"><span class="hs-identifier hs-var">exprIsTopLevelBindable</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621680962627"><span class="hs-identifier hs-var">expr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680962622"><span class="hs-identifier hs-var">expr_ty</span></a></span><span>
</span><span id="line-672"></span><span>         </span><span class="hs-comment">-- No wrapping needed if the type is lifted, or is a literal string</span><span>
</span><span id="line-673"></span><span>         </span><span class="hs-comment">-- or if we are wrapping it in one or more value lambdas</span><span>
</span><span id="line-674"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680962621"><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962621"><span class="hs-identifier hs-var">expr1</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Id]
-&gt; Level
-&gt; LevelEnv
-&gt; RecFlag
-&gt; Bool
-&gt; Maybe Int
-&gt; CoreExprWithFVs
-&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlFloatRhs"><span class="hs-identifier hs-var">lvlFloatRhs</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962625"><span class="hs-identifier hs-var">abs_vars</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962630"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962619"><span class="hs-identifier hs-var">rhs_env</span></a></span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="GHC.Types.Basic.html#NonRecursive"><span class="hs-identifier hs-var">NonRecursive</span></a></span><span>
</span><span id="line-675"></span><span>                              </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe (Int, StrictSig) -&gt; Bool
forall a. Maybe a -&gt; Bool
</span><a href="../../base/src/Data.Maybe.html#isJust"><span class="hs-identifier hs-var">isJust</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (Int, StrictSig)
</span><a href="#local-6989586621680962617"><span class="hs-identifier hs-var">mb_bot_str</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-676"></span><span>                              </span><span class="annot"><span class="annottext">Maybe Int
forall a. Maybe a
</span><a href="#local-6989586621680962616"><span class="hs-identifier hs-var">join_arity_maybe</span></a></span><span>
</span><span id="line-677"></span><span>                              </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962631"><span class="hs-identifier hs-var">ann_expr</span></a></span><span>
</span><span id="line-678"></span><span>                  </span><span class="hs-comment">-- Treat the expr just like a right-hand side</span><span>
</span><span id="line-679"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621680962615"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962615"><span class="hs-identifier hs-var">var</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LevelledExpr -&gt; Maybe Int -&gt; Bool -&gt; LvlM Id
</span><a href="GHC.Core.Opt.SetLevels.html#newLvlVar"><span class="hs-identifier hs-var">newLvlVar</span></a></span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962621"><span class="hs-identifier hs-var">expr1</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Int
forall a. Maybe a
</span><a href="#local-6989586621680962616"><span class="hs-identifier hs-var">join_arity_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962613"><span class="hs-identifier hs-var">is_mk_static</span></a></span><span>
</span><span id="line-680"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680962612"><span class="annot"><span class="annottext">var2 :: Id
</span><a href="#local-6989586621680962612"><span class="hs-identifier hs-var hs-var">var2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Int -&gt; Maybe (Int, StrictSig) -&gt; Id
</span><a href="GHC.Core.Opt.SetLevels.html#annotateBotStr"><span class="hs-identifier hs-var">annotateBotStr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962615"><span class="hs-identifier hs-var">var</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962610"><span class="hs-identifier hs-var">float_n_lams</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (Int, StrictSig)
</span><a href="#local-6989586621680962617"><span class="hs-identifier hs-var">mb_bot_str</span></a></span><span>
</span><span id="line-681"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">LevelledExpr -&gt; LvlM LevelledExpr
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelledBind -&gt; LevelledExpr -&gt; LevelledExpr
forall b. Bind b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Let"><span class="hs-identifier hs-var">Let</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelledBndr -&gt; LevelledExpr -&gt; LevelledBind
forall b. b -&gt; Expr b -&gt; Bind b
</span><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-var">NonRec</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; FloatSpec -&gt; LevelledBndr
forall t. Id -&gt; t -&gt; TaggedBndr t
</span><a href="GHC.Core.html#TB"><span class="hs-identifier hs-var">TB</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962612"><span class="hs-identifier hs-var">var2</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Level -&gt; FloatSpec
</span><a href="GHC.Core.Opt.SetLevels.html#FloatMe"><span class="hs-identifier hs-var">FloatMe</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962630"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962621"><span class="hs-identifier hs-var">expr1</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-682"></span><span>                     </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelledExpr -&gt; [Id] -&gt; LevelledExpr
forall b. Expr b -&gt; [Id] -&gt; Expr b
</span><a href="GHC.Core.html#mkVarApps"><span class="hs-identifier hs-var">mkVarApps</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; LevelledExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962612"><span class="hs-identifier hs-var">var2</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962625"><span class="hs-identifier hs-var">abs_vars</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-683"></span><span>
</span><span id="line-684"></span><span>  </span><span class="hs-comment">-- OK, so the float has an unlifted type (not top-level bindable)</span><span>
</span><span id="line-685"></span><span>  </span><span class="hs-comment">--     and no new value lambdas (float_is_new_lam is False)</span><span>
</span><span id="line-686"></span><span>  </span><span class="hs-comment">-- Try for the boxing strategy</span><span>
</span><span id="line-687"></span><span>  </span><span class="hs-comment">-- See Note [Floating MFEs of unlifted type]</span><span>
</span><span id="line-688"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962607"><span class="hs-identifier hs-var">escapes_value_lam</span></a></span><span>
</span><span id="line-689"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962606"><span class="hs-identifier hs-var">expr_ok_for_spec</span></a></span><span> </span><span class="hs-comment">-- Boxing/unboxing isn't worth it for cheap expressions</span><span>
</span><span id="line-690"></span><span>                         </span><span class="hs-comment">-- See Note [Test cheapness with exprOkForSpeculation]</span><span>
</span><span id="line-691"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680962605"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680962605"><span class="hs-identifier hs-var">tc</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Maybe (TyCon, [Type])
Type -&gt; Maybe (TyCon, [Type])
</span><a href="GHC.Core.Type.html#splitTyConApp_maybe"><span class="hs-identifier hs-var">splitTyConApp_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680962622"><span class="hs-identifier hs-var">expr_ty</span></a></span><span>
</span><span id="line-692"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680962604"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680962604"><span class="hs-identifier hs-var">dc</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Maybe DataCon
</span><a href="GHC.Builtin.Types.html#boxingDataCon_maybe"><span class="hs-identifier hs-var">boxingDataCon_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680962605"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-693"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680962602"><span class="annot"><span class="annottext">dc_res_ty :: Type
</span><a href="#local-6989586621680962602"><span class="hs-identifier hs-var hs-var">dc_res_ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DataCon -&gt; Type
</span><a href="GHC.Core.DataCon.html#dataConOrigResTy"><span class="hs-identifier hs-var">dataConOrigResTy</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680962604"><span class="hs-identifier hs-var">dc</span></a></span><span>  </span><span class="hs-comment">-- No free type variables</span><span>
</span><span id="line-694"></span><span>        </span><span class="hs-special">[</span><span id="local-6989586621680962601"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962601"><span class="hs-identifier hs-var">bx_bndr</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962600"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962600"><span class="hs-identifier hs-var">ubx_bndr</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; [Id]
</span><a href="GHC.Types.Id.html#mkTemplateLocals"><span class="hs-identifier hs-var">mkTemplateLocals</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680962602"><span class="hs-identifier hs-var">dc_res_ty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680962622"><span class="hs-identifier hs-var">expr_ty</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-695"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680962598"><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962598"><span class="hs-identifier hs-var">expr1</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; CoreExprWithFVs -&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlExpr"><span class="hs-identifier hs-var">lvlExpr</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962619"><span class="hs-identifier hs-var">rhs_env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962631"><span class="hs-identifier hs-var">ann_expr</span></a></span><span>
</span><span id="line-696"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680962597"><span class="annot"><span class="annottext">l1r :: Level
</span><a href="#local-6989586621680962597"><span class="hs-identifier hs-var hs-var">l1r</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#incMinorLvlFrom"><span class="hs-identifier hs-var">incMinorLvlFrom</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962619"><span class="hs-identifier hs-var">rhs_env</span></a></span><span>
</span><span id="line-697"></span><span>             </span><span id="local-6989586621680962595"><span class="annot"><span class="annottext">float_rhs :: LevelledExpr
</span><a href="#local-6989586621680962595"><span class="hs-identifier hs-var hs-var">float_rhs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[LevelledBndr] -&gt; LevelledExpr -&gt; LevelledExpr
forall b. [b] -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#mkLams"><span class="hs-identifier hs-var">mkLams</span></a></span><span> </span><span class="annot"><span class="annottext">[LevelledBndr]
</span><a href="#local-6989586621680962594"><span class="hs-identifier hs-var">abs_vars_w_lvls</span></a></span><span> </span><span class="annot"><span class="annottext">(LevelledExpr -&gt; LevelledExpr) -&gt; LevelledExpr -&gt; LevelledExpr
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-698"></span><span>                         </span><span class="annot"><span class="annottext">LevelledExpr
-&gt; LevelledBndr
-&gt; Type
-&gt; [(AltCon, [LevelledBndr], LevelledExpr)]
-&gt; LevelledExpr
forall b. Expr b -&gt; b -&gt; Type -&gt; [Alt b] -&gt; Expr b
</span><a href="GHC.Core.html#Case"><span class="hs-identifier hs-var">Case</span></a></span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962598"><span class="hs-identifier hs-var">expr1</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Level -&gt; Id -&gt; LevelledBndr
</span><a href="GHC.Core.Opt.SetLevels.html#stayPut"><span class="hs-identifier hs-var">stayPut</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962597"><span class="hs-identifier hs-var">l1r</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962600"><span class="hs-identifier hs-var">ubx_bndr</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680962602"><span class="hs-identifier hs-var">dc_res_ty</span></a></span><span>
</span><span id="line-699"></span><span>                             </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">AltCon
</span><a href="GHC.Core.html#DEFAULT"><span class="hs-identifier hs-var">DEFAULT</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">DataCon -&gt; [LevelledExpr] -&gt; LevelledExpr
forall b. DataCon -&gt; [Arg b] -&gt; Arg b
</span><a href="GHC.Core.html#mkConApp"><span class="hs-identifier hs-var">mkConApp</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680962604"><span class="hs-identifier hs-var">dc</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Id -&gt; LevelledExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962600"><span class="hs-identifier hs-var">ubx_bndr</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-700"></span><span>
</span><span id="line-701"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621680962591"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962591"><span class="hs-identifier hs-var">var</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LevelledExpr -&gt; Maybe Int -&gt; Bool -&gt; LvlM Id
</span><a href="GHC.Core.Opt.SetLevels.html#newLvlVar"><span class="hs-identifier hs-var">newLvlVar</span></a></span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962595"><span class="hs-identifier hs-var">float_rhs</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Int
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962613"><span class="hs-identifier hs-var">is_mk_static</span></a></span><span>
</span><span id="line-702"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680962590"><span class="annot"><span class="annottext">l1u :: Level
</span><a href="#local-6989586621680962590"><span class="hs-identifier hs-var hs-var">l1u</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#incMinorLvlFrom"><span class="hs-identifier hs-var">incMinorLvlFrom</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962633"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-703"></span><span>             </span><span id="local-6989586621680962589"><span class="annot"><span class="annottext">use_expr :: LevelledExpr
</span><a href="#local-6989586621680962589"><span class="hs-identifier hs-var hs-var">use_expr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelledExpr
-&gt; LevelledBndr
-&gt; Type
-&gt; [(AltCon, [LevelledBndr], LevelledExpr)]
-&gt; LevelledExpr
forall b. Expr b -&gt; b -&gt; Type -&gt; [Alt b] -&gt; Expr b
</span><a href="GHC.Core.html#Case"><span class="hs-identifier hs-var">Case</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelledExpr -&gt; [Id] -&gt; LevelledExpr
forall b. Expr b -&gt; [Id] -&gt; Expr b
</span><a href="GHC.Core.html#mkVarApps"><span class="hs-identifier hs-var">mkVarApps</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; LevelledExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962591"><span class="hs-identifier hs-var">var</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962625"><span class="hs-identifier hs-var">abs_vars</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-704"></span><span>                             </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Level -&gt; Id -&gt; LevelledBndr
</span><a href="GHC.Core.Opt.SetLevels.html#stayPut"><span class="hs-identifier hs-var">stayPut</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962590"><span class="hs-identifier hs-var">l1u</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962601"><span class="hs-identifier hs-var">bx_bndr</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680962622"><span class="hs-identifier hs-var">expr_ty</span></a></span><span>
</span><span id="line-705"></span><span>                             </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; AltCon
</span><a href="GHC.Core.html#DataAlt"><span class="hs-identifier hs-var">DataAlt</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680962604"><span class="hs-identifier hs-var">dc</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Level -&gt; Id -&gt; LevelledBndr
</span><a href="GHC.Core.Opt.SetLevels.html#stayPut"><span class="hs-identifier hs-var">stayPut</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962590"><span class="hs-identifier hs-var">l1u</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962600"><span class="hs-identifier hs-var">ubx_bndr</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id -&gt; LevelledExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962600"><span class="hs-identifier hs-var">ubx_bndr</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-706"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">LevelledExpr -&gt; LvlM LevelledExpr
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelledBind -&gt; LevelledExpr -&gt; LevelledExpr
forall b. Bind b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Let"><span class="hs-identifier hs-var">Let</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelledBndr -&gt; LevelledExpr -&gt; LevelledBind
forall b. b -&gt; Expr b -&gt; Bind b
</span><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-var">NonRec</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; FloatSpec -&gt; LevelledBndr
forall t. Id -&gt; t -&gt; TaggedBndr t
</span><a href="GHC.Core.html#TB"><span class="hs-identifier hs-var">TB</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962591"><span class="hs-identifier hs-var">var</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Level -&gt; FloatSpec
</span><a href="GHC.Core.Opt.SetLevels.html#FloatMe"><span class="hs-identifier hs-var">FloatMe</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962630"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962595"><span class="hs-identifier hs-var">float_rhs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-707"></span><span>                     </span><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962589"><span class="hs-identifier hs-var">use_expr</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-708"></span><span>
</span><span id="line-709"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>          </span><span class="hs-comment">-- e.g. do not float unboxed tuples</span><span>
</span><span id="line-710"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; CoreExprWithFVs -&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlExpr"><span class="hs-identifier hs-var">lvlExpr</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962633"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962631"><span class="hs-identifier hs-var">ann_expr</span></a></span><span>
</span><span id="line-711"></span><span>
</span><span id="line-712"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-713"></span><span>    </span><span id="local-6989586621680962627"><span class="annot"><span class="annottext">expr :: Expr Id
</span><a href="#local-6989586621680962627"><span class="hs-identifier hs-var hs-var">expr</span></a></span></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs -&gt; Expr Id
forall bndr annot. AnnExpr bndr annot -&gt; Expr bndr
</span><a href="GHC.Core.html#deAnnotate"><span class="hs-identifier hs-var">deAnnotate</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962631"><span class="hs-identifier hs-var">ann_expr</span></a></span><span>
</span><span id="line-714"></span><span>    </span><span id="local-6989586621680962622"><span class="annot"><span class="annottext">expr_ty :: Type
</span><a href="#local-6989586621680962622"><span class="hs-identifier hs-var hs-var">expr_ty</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Expr Id -&gt; Type
</span><a href="GHC.Core.Utils.html#exprType"><span class="hs-identifier hs-var">exprType</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621680962627"><span class="hs-identifier hs-var">expr</span></a></span><span>
</span><span id="line-715"></span><span>    </span><span id="local-6989586621680962628"><span class="annot"><span class="annottext">fvs :: FVAnn
</span><a href="#local-6989586621680962628"><span class="hs-identifier hs-var hs-var">fvs</span></a></span></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs -&gt; FVAnn
</span><a href="GHC.Core.FVs.html#freeVarsOf"><span class="hs-identifier hs-var">freeVarsOf</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962631"><span class="hs-identifier hs-var">ann_expr</span></a></span><span>
</span><span id="line-716"></span><span>    </span><span id="local-6989586621680962588"><span class="annot"><span class="annottext">fvs_ty :: TyCoVarSet
</span><a href="#local-6989586621680962588"><span class="hs-identifier hs-var hs-var">fvs_ty</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; TyCoVarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfType"><span class="hs-identifier hs-var">tyCoVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680962622"><span class="hs-identifier hs-var">expr_ty</span></a></span><span>
</span><span id="line-717"></span><span>    </span><span id="local-6989586621680962587"><span class="annot"><span class="annottext">is_bot :: Bool
</span><a href="#local-6989586621680962587"><span class="hs-identifier hs-var hs-var">is_bot</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe (Int, StrictSig) -&gt; Bool
forall s. Maybe (Int, s) -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#isBottomThunk"><span class="hs-identifier hs-var">isBottomThunk</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (Int, StrictSig)
</span><a href="#local-6989586621680962617"><span class="hs-identifier hs-var">mb_bot_str</span></a></span><span>
</span><span id="line-718"></span><span>    </span><span id="local-6989586621680962585"><span class="annot"><span class="annottext">is_function :: Bool
</span><a href="#local-6989586621680962585"><span class="hs-identifier hs-var hs-var">is_function</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#isFunction"><span class="hs-identifier hs-var">isFunction</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962631"><span class="hs-identifier hs-var">ann_expr</span></a></span><span>
</span><span id="line-719"></span><span>    </span><span id="local-6989586621680962617"><span class="annot"><span class="annottext">mb_bot_str :: Maybe (Int, StrictSig)
</span><a href="#local-6989586621680962617"><span class="hs-identifier hs-var hs-var">mb_bot_str</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Expr Id -&gt; Maybe (Int, StrictSig)
</span><a href="GHC.Core.Opt.Arity.html#exprBotStrictness_maybe"><span class="hs-identifier hs-var">exprBotStrictness_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621680962627"><span class="hs-identifier hs-var">expr</span></a></span><span>
</span><span id="line-720"></span><span>                           </span><span class="hs-comment">-- See Note [Bottoming floats]</span><span>
</span><span id="line-721"></span><span>                           </span><span class="hs-comment">-- esp Bottoming floats (2)</span><span>
</span><span id="line-722"></span><span>    </span><span id="local-6989586621680962606"><span class="annot"><span class="annottext">expr_ok_for_spec :: Bool
</span><a href="#local-6989586621680962606"><span class="hs-identifier hs-var hs-var">expr_ok_for_spec</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Expr Id -&gt; Bool
</span><a href="GHC.Core.Utils.html#exprOkForSpeculation"><span class="hs-identifier hs-var">exprOkForSpeculation</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621680962627"><span class="hs-identifier hs-var">expr</span></a></span><span>
</span><span id="line-723"></span><span>    </span><span id="local-6989586621680962630"><span class="annot"><span class="annottext">dest_lvl :: Level
</span><a href="#local-6989586621680962630"><span class="hs-identifier hs-var hs-var">dest_lvl</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; FVAnn -&gt; TyCoVarSet -&gt; Bool -&gt; Bool -&gt; Bool -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#destLevel"><span class="hs-identifier hs-var">destLevel</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962633"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">FVAnn
</span><a href="#local-6989586621680962628"><span class="hs-identifier hs-var">fvs</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVarSet
</span><a href="#local-6989586621680962588"><span class="hs-identifier hs-var">fvs_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962585"><span class="hs-identifier hs-var">is_function</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962587"><span class="hs-identifier hs-var">is_bot</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-724"></span><span>    </span><span id="local-6989586621680962625"><span class="annot"><span class="annottext">abs_vars :: [Id]
</span><a href="#local-6989586621680962625"><span class="hs-identifier hs-var hs-var">abs_vars</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level -&gt; LevelEnv -&gt; FVAnn -&gt; [Id]
</span><a href="GHC.Core.Opt.SetLevels.html#abstractVars"><span class="hs-identifier hs-var">abstractVars</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962630"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962633"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">FVAnn
</span><a href="#local-6989586621680962628"><span class="hs-identifier hs-var">fvs</span></a></span><span>
</span><span id="line-725"></span><span>
</span><span id="line-726"></span><span>    </span><span class="hs-comment">-- float_is_new_lam: the floated thing will be a new value lambda</span><span>
</span><span id="line-727"></span><span>    </span><span class="hs-comment">-- replacing, say (g (x+4)) by (lvl x).  No work is saved, nor is</span><span>
</span><span id="line-728"></span><span>    </span><span class="hs-comment">-- allocation saved.  The benefit is to get it to the top level</span><span>
</span><span id="line-729"></span><span>    </span><span class="hs-comment">-- and hence out of the body of this function altogether, making</span><span>
</span><span id="line-730"></span><span>    </span><span class="hs-comment">-- it smaller and more inlinable</span><span>
</span><span id="line-731"></span><span>    </span><span id="local-6989586621680962623"><span class="annot"><span class="annottext">float_is_new_lam :: Bool
</span><a href="#local-6989586621680962623"><span class="hs-identifier hs-var hs-var">float_is_new_lam</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962610"><span class="hs-identifier hs-var">float_n_lams</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>
</span><span id="line-732"></span><span>    </span><span id="local-6989586621680962610"><span class="annot"><span class="annottext">float_n_lams :: Int
</span><a href="#local-6989586621680962610"><span class="hs-identifier hs-var hs-var">float_n_lams</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Bool) -&gt; [Id] -&gt; Int
forall a. (a -&gt; Bool) -&gt; [a] -&gt; Int
</span><a href="GHC.Utils.Misc.html#count"><span class="hs-identifier hs-var">count</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isId"><span class="hs-identifier hs-var">isId</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962625"><span class="hs-identifier hs-var">abs_vars</span></a></span><span>
</span><span id="line-733"></span><span>
</span><span id="line-734"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680962619"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962619"><span class="hs-identifier hs-var">rhs_env</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962594"><span class="annot"><span class="annottext">[LevelledBndr]
</span><a href="#local-6989586621680962594"><span class="hs-identifier hs-var">abs_vars_w_lvls</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Level -&gt; [Id] -&gt; (LevelEnv, [LevelledBndr])
</span><a href="GHC.Core.Opt.SetLevels.html#lvlLamBndrs"><span class="hs-identifier hs-var">lvlLamBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962633"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962630"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962625"><span class="hs-identifier hs-var">abs_vars</span></a></span><span>
</span><span id="line-735"></span><span>
</span><span id="line-736"></span><span>    </span><span id="local-6989586621680962616"><span class="annot"><span class="annottext">join_arity_maybe :: Maybe a
</span><a href="#local-6989586621680962616"><span class="hs-identifier hs-var hs-var">join_arity_maybe</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe a
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-737"></span><span>
</span><span id="line-738"></span><span>    </span><span id="local-6989586621680962613"><span class="annot"><span class="annottext">is_mk_static :: Bool
</span><a href="#local-6989586621680962613"><span class="hs-identifier hs-var hs-var">is_mk_static</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe (Expr Id, Type, Expr Id, Expr Id) -&gt; Bool
forall a. Maybe a -&gt; Bool
</span><a href="../../base/src/Data.Maybe.html#isJust"><span class="hs-identifier hs-var">isJust</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Expr Id -&gt; Maybe (Expr Id, Type, Expr Id, Expr Id)
</span><a href="GHC.Core.Utils.html#collectMakeStaticArgs"><span class="hs-identifier hs-var">collectMakeStaticArgs</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621680962627"><span class="hs-identifier hs-var">expr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-739"></span><span>        </span><span class="hs-comment">-- Yuk: See Note [Grand plan for static forms] in GHC.Iface.Tidy.StaticPtrTable</span><span>
</span><span id="line-740"></span><span>
</span><span id="line-741"></span><span>        </span><span class="hs-comment">-- A decision to float entails let-binding this thing, and we only do</span><span>
</span><span id="line-742"></span><span>        </span><span class="hs-comment">-- that if we'll escape a value lambda, or will go to the top level.</span><span>
</span><span id="line-743"></span><span>    </span><span id="local-6989586621680962624"><span class="annot"><span class="annottext">float_me :: Bool
</span><a href="#local-6989586621680962624"><span class="hs-identifier hs-var hs-var">float_me</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962578"><span class="hs-identifier hs-var">saves_work</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962577"><span class="hs-identifier hs-var">saves_alloc</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962613"><span class="hs-identifier hs-var">is_mk_static</span></a></span><span>
</span><span id="line-744"></span><span>
</span><span id="line-745"></span><span>    </span><span class="hs-comment">-- We can save work if we can move a redex outside a value lambda</span><span>
</span><span id="line-746"></span><span>    </span><span class="hs-comment">-- But if float_is_new_lam is True, then the redex is wrapped in a</span><span>
</span><span id="line-747"></span><span>    </span><span class="hs-comment">-- a new lambda, so no work is saved</span><span>
</span><span id="line-748"></span><span>    </span><span id="local-6989586621680962578"><span class="annot"><span class="annottext">saves_work :: Bool
</span><a href="#local-6989586621680962578"><span class="hs-identifier hs-var hs-var">saves_work</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962607"><span class="hs-identifier hs-var">escapes_value_lam</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962623"><span class="hs-identifier hs-var">float_is_new_lam</span></a></span><span>
</span><span id="line-749"></span><span>
</span><span id="line-750"></span><span>    </span><span id="local-6989586621680962607"><span class="annot"><span class="annottext">escapes_value_lam :: Bool
</span><a href="#local-6989586621680962607"><span class="hs-identifier hs-var hs-var">escapes_value_lam</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962630"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">Level -&gt; Level -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#ltMajLvl"><span class="hs-operator hs-var">`ltMajLvl`</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#le_ctxt_lvl"><span class="hs-identifier hs-var hs-var">le_ctxt_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962633"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-751"></span><span>                  </span><span class="hs-comment">-- See Note [Escaping a value lambda]</span><span>
</span><span id="line-752"></span><span>
</span><span id="line-753"></span><span>    </span><span class="hs-comment">-- See Note [Floating to the top]</span><span>
</span><span id="line-754"></span><span>    </span><span id="local-6989586621680962577"><span class="annot"><span class="annottext">saves_alloc :: Bool
</span><a href="#local-6989586621680962577"><span class="hs-identifier hs-var hs-var">saves_alloc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>  </span><span class="annot"><span class="annottext">Level -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#isTopLvl"><span class="hs-identifier hs-var">isTopLvl</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962630"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span>
</span><span id="line-755"></span><span>                </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#floatConsts"><span class="hs-identifier hs-var">floatConsts</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962633"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-756"></span><span>                </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962632"><span class="hs-identifier hs-var">strict_ctxt</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962587"><span class="hs-identifier hs-var">is_bot</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Expr Id -&gt; Bool
</span><a href="GHC.Core.Utils.html#exprIsHNF"><span class="hs-identifier hs-var">exprIsHNF</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621680962627"><span class="hs-identifier hs-var">expr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-757"></span><span>
</span><span id="line-758"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#hasFreeJoin"><span class="hs-identifier hs-type">hasFreeJoin</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#DVarSet"><span class="hs-identifier hs-type">DVarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-759"></span><span class="hs-comment">-- Has a free join point which is not being floated to top level.</span><span>
</span><span id="line-760"></span><span class="hs-comment">-- (In the latter case it won't be a join point any more.)</span><span>
</span><span id="line-761"></span><span class="hs-comment">-- Not treating top-level ones specially had a massive effect</span><span>
</span><span id="line-762"></span><span class="hs-comment">-- on nofib/minimax/Prog.prog</span><span>
</span><span id="line-763"></span><span id="hasFreeJoin"><span class="annot"><span class="annottext">hasFreeJoin :: LevelEnv -&gt; FVAnn -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#hasFreeJoin"><span class="hs-identifier hs-var hs-var">hasFreeJoin</span></a></span></span><span> </span><span id="local-6989586621680962575"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962575"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680962574"><span class="annot"><span class="annottext">FVAnn
</span><a href="#local-6989586621680962574"><span class="hs-identifier hs-var">fvs</span></a></span></span><span>
</span><span id="line-764"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Id -&gt; Bool) -&gt; LevelEnv -&gt; FVAnn -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#maxFvLevel"><span class="hs-identifier hs-var">maxFvLevel</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Id.html#isJoinId"><span class="hs-identifier hs-var">isJoinId</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962575"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">FVAnn
</span><a href="#local-6989586621680962574"><span class="hs-identifier hs-var">fvs</span></a></span><span> </span><span class="annot"><span class="annottext">Level -&gt; Level -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="GHC.Core.Opt.SetLevels.html#tOP_LEVEL"><span class="hs-identifier hs-var">tOP_LEVEL</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-765"></span><span>
</span><span id="line-766"></span><span id="local-6989586621680963217"><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#isBottomThunk"><span class="hs-identifier hs-type">isBottomThunk</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Basic.html#Arity"><span class="hs-identifier hs-type">Arity</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621680963217"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span></span><span>
</span><span id="line-767"></span><span class="hs-comment">-- See Note [Bottoming floats] (2)</span><span>
</span><span id="line-768"></span><span id="isBottomThunk"><span class="annot"><span class="annottext">isBottomThunk :: forall s. Maybe (Int, s) -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#isBottomThunk"><span class="hs-identifier hs-var hs-var">isBottomThunk</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">s
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>   </span><span class="hs-comment">-- Zero arity</span><span>
</span><span id="line-769"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#isBottomThunk"><span class="hs-identifier hs-var">isBottomThunk</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (Int, s)
</span><span class="hs-identifier">_</span></span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-770"></span><span>
</span><span id="line-771"></span><span class="hs-comment">{- Note [Floating to the top]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We are keen to float something to the top level, even if it does not
escape a value lambda (and hence save work), for two reasons:

  * Doing so makes the function smaller, by floating out
    bottoming expressions, or integer or string literals.  That in
    turn makes it easier to inline, with less duplication.

  * (Minor) Doing so may turn a dynamic allocation (done by machine
    instructions) into a static one. Minor because we are assuming
    we are not escaping a value lambda.

But do not so if:
     - the context is a strict, and
     - the expression is not a HNF, and
     - the expression is not bottoming

Exammples:

* Bottoming
      f x = case x of
              0 -&gt; error &lt;big thing&gt;
              _ -&gt; x+1
  Here we want to float (error &lt;big thing&gt;) to top level, abstracting
  over 'x', so as to make f's RHS smaller.

* HNF
      f = case y of
            True  -&gt; p:q
            False -&gt; blah
  We may as well float the (p:q) so it becomes a static data structure.

* Case scrutinee
      f = case g True of ....
  Don't float (g True) to top level; then we have the admin of a
  top-level thunk to worry about, with zero gain.

* Case alternative
      h = case y of
             True  -&gt; g True
             False -&gt; False
  Don't float (g True) to the top level

* Arguments
     t = f (g True)
  If f is lazy, we /do/ float (g True) because then we can allocate
  the thunk statically rather than dynamically.  But if f is strict
  we don't (see the use of idStrictness in lvlApp).  It's not clear
  if this test is worth the bother: it's only about CAFs!

It's controlled by a flag (floatConsts), because doing this too
early loses opportunities for RULES which (needless to say) are
important in some nofib programs (gcd is an example).  [SPJ note:
I think this is obsolete; the flag seems always on.]

Note [Floating join point bindings]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mostly we only float a join point if it can /stay/ a join point.  But
there is one exception: if it can go to the top level (#13286).
Consider
  f x = joinrec j y n = &lt;...j y' n'...&gt;
        in jump j x 0

Here we may just as well produce
  j y n = &lt;....j y' n'...&gt;
  f x = j x 0

and now there is a chance that 'f' will be inlined at its call sites.
It shouldn't make a lot of difference, but these tests
  perf/should_run/MethSharing
  simplCore/should_compile/spec-inline
and one nofib program, all improve if you do float to top, because
of the resulting inlining of f.  So ok, let's do it.

Note [Free join points]
~~~~~~~~~~~~~~~~~~~~~~~
We never float a MFE that has a free join-point variable.  You might think
this can never occur.  After all, consider
     join j x = ...
     in ....(jump j x)....
How might we ever want to float that (jump j x)?
  * If it would escape a value lambda, thus
        join j x = ... in (\y. ...(jump j x)... )
    then 'j' isn't a valid join point in the first place.

But consider
     join j x = .... in
     joinrec j2 y =  ...(jump j x)...(a+b)....

Since j2 is recursive, it /is/ worth floating (a+b) out of the joinrec.
But it is emphatically /not/ good to float the (jump j x) out:
 (a) 'j' will stop being a join point
 (b) In any case, jumping to 'j' must be an exit of the j2 loop, so no
     work would be saved by floating it out of the \y.

Even if we floated 'j' to top level, (b) would still hold.

Bottom line: never float a MFE that has a free JoinId.

Note [Floating MFEs of unlifted type]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Suppose we have
   case f x of (r::Int#) -&gt; blah
we'd like to float (f x). But it's not trivial because it has type
Int#, and we don't want to evaluate it too early.  But we can instead
float a boxed version
   y = case f x of r -&gt; I# r
and replace the original (f x) with
   case (case y of I# r -&gt; r) of r -&gt; blah

Being able to float unboxed expressions is sometimes important; see
#12603.  I'm not sure how /often/ it is important, but it's
not hard to achieve.

We only do it for a fixed collection of types for which we have a
convenient boxing constructor (see boxingDataCon_maybe).  In
particular we /don't/ do it for unboxed tuples; it's better to float
the components of the tuple individually.

I did experiment with a form of boxing that works for any type, namely
wrapping in a function.  In our example

   let y = case f x of r -&gt; \v. f x
   in case y void of r -&gt; blah

It works fine, but it's 50% slower (based on some crude benchmarking).
I suppose we could do it for types not covered by boxingDataCon_maybe,
but it's more code and I'll wait to see if anyone wants it.

Note [Test cheapness with exprOkForSpeculation]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We don't want to float very cheap expressions by boxing and unboxing.
But we use exprOkForSpeculation for the test, not exprIsCheap.
Why?  Because it's important /not/ to transform
     f (a /# 3)
to
     f (case bx of I# a -&gt; a /# 3)
and float bx = I# (a /# 3), because the application of f no
longer obeys the let/app invariant.  But (a /# 3) is ok-for-spec
due to a special hack that says division operators can't fail
when the denominator is definitely non-zero.  And yet that
same expression says False to exprIsCheap.  Simplest way to
guarantee the let/app invariant is to use the same function!

If an expression is okay for speculation, we could also float it out
*without* boxing and unboxing, since evaluating it early is okay.
However, it turned out to usually be better not to float such expressions,
since they tend to be extremely cheap things like (x +# 1#). Even the
cost of spilling the let-bound variable to the stack across a call may
exceed the cost of recomputing such an expression. (And we can't float
unlifted bindings to top-level.)

We could try to do something smarter here, and float out expensive yet
okay-for-speculation things, such as division by non-zero constants.
But I suspect it's a narrow target.

Note [Bottoming floats]
~~~~~~~~~~~~~~~~~~~~~~~
If we see
        f = \x. g (error &quot;urk&quot;)
we'd like to float the call to error, to get
        lvl = error &quot;urk&quot;
        f = \x. g lvl

But, as ever, we need to be careful:

(1) We want to float a bottoming
    expression even if it has free variables:
        f = \x. g (let v = h x in error (&quot;urk&quot; ++ v))
    Then we'd like to abstract over 'x' can float the whole arg of g:
        lvl = \x. let v = h x in error (&quot;urk&quot; ++ v)
        f = \x. g (lvl x)
    To achieve this we pass is_bot to destLevel

(2) We do not do this for lambdas that return
    bottom.  Instead we treat the /body/ of such a function specially,
    via point (1).  For example:
        f = \x. ....(\y z. if x then error y else error z)....
    ===&gt;
        lvl = \x z y. if b then error y else error z
        f = \x. ...(\y z. lvl x z y)...
    (There is no guarantee that we'll choose the perfect argument order.)

(3) If we have a /binding/ that returns bottom, we want to float it to top
    level, even if it has free vars (point (1)), and even it has lambdas.
    Example:
       ... let { v = \y. error (show x ++ show y) } in ...
    We want to abstract over x and float the whole thing to top:
       lvl = \xy. errror (show x ++ show y)
       ...let {v = lvl x} in ...

    Then of course we don't want to separately float the body (error ...)
    as /another/ MFE, so we tell lvlFloatRhs not to do that, via the is_bot
    argument.

See Maessen's paper 1999 &quot;Bottom extraction: factoring error handling out
of functional programs&quot; (unpublished I think).

When we do this, we set the strictness and arity of the new bottoming
Id, *immediately*, for three reasons:

  * To prevent the abstracted thing being immediately inlined back in again
    via preInlineUnconditionally.  The latter has a test for bottoming Ids
    to stop inlining them, so we'd better make sure it *is* a bottoming Id!

  * So that it's properly exposed as such in the interface file, even if
    this is all happening after strictness analysis.

  * In case we do CSE with the same expression that *is* marked bottom
        lvl          = error &quot;urk&quot;
          x{str=bot) = error &quot;urk&quot;
    Here we don't want to replace 'x' with 'lvl', else we may get Lint
    errors, e.g. via a case with empty alternatives:  (case x of {})
    Lint complains unless the scrutinee of such a case is clearly bottom.

    This was reported in #11290.   But since the whole bottoming-float
    thing is based on the cheap-and-cheerful exprIsDeadEnd, I'm not sure
    that it'll nail all such cases.

Note [Bottoming floats: eta expansion] c.f Note [Bottoming floats]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tiresomely, though, the simplifier has an invariant that the manifest
arity of the RHS should be the same as the arity; but we can't call
etaExpand during GHC.Core.Opt.SetLevels because it works over a decorated form of
CoreExpr.  So we do the eta expansion later, in GHC.Core.Opt.FloatOut.
But we should only eta-expand if the RHS doesn't already have the right
exprArity, otherwise we get unnecessary top-level bindings if the RHS was
trivial after the next run of the Simplifier.

Note [Case MFEs]
~~~~~~~~~~~~~~~~
We don't float a case expression as an MFE from a strict context.  Why not?
Because in doing so we share a tiny bit of computation (the switch) but
in exchange we build a thunk, which is bad.  This case reduces allocation
by 7% in spectral/puzzle (a rather strange benchmark) and 1.2% in real/fem.
Doesn't change any other allocation at all.

We will make a separate decision for the scrutinee and alternatives.

However this can have a knock-on effect for fusion: consider
    \v -&gt; foldr k z (case x of I# y -&gt; build ..y..)
Perhaps we can float the entire (case x of ...) out of the \v.  Then
fusion will not happen, but we will get more sharing.  But if we don't
float the case (as advocated here) we won't float the (build ...y..)
either, so fusion will happen.  It can be a big effect, esp in some
artificial benchmarks (e.g. integer, queens), but there is no perfect
answer.

-}</span><span>
</span><span id="line-1021"></span><span>
</span><span id="line-1022"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#annotateBotStr"><span class="hs-identifier hs-type">annotateBotStr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#Arity"><span class="hs-identifier hs-type">Arity</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Basic.html#Arity"><span class="hs-identifier hs-type">Arity</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Demand.html#StrictSig"><span class="hs-identifier hs-type">StrictSig</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>
</span><span id="line-1023"></span><span class="hs-comment">-- See Note [Bottoming floats] for why we want to add</span><span>
</span><span id="line-1024"></span><span class="hs-comment">-- bottoming information right now</span><span>
</span><span id="line-1025"></span><span class="hs-comment">--</span><span>
</span><span id="line-1026"></span><span class="hs-comment">-- n_extra are the number of extra value arguments added during floating</span><span>
</span><span id="line-1027"></span><span id="annotateBotStr"><span class="annot"><span class="annottext">annotateBotStr :: Id -&gt; Int -&gt; Maybe (Int, StrictSig) -&gt; Id
</span><a href="GHC.Core.Opt.SetLevels.html#annotateBotStr"><span class="hs-identifier hs-var hs-var">annotateBotStr</span></a></span></span><span> </span><span id="local-6989586621680962570"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962570"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span id="local-6989586621680962569"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962569"><span class="hs-identifier hs-var">n_extra</span></a></span></span><span> </span><span id="local-6989586621680962568"><span class="annot"><span class="annottext">Maybe (Int, StrictSig)
</span><a href="#local-6989586621680962568"><span class="hs-identifier hs-var">mb_str</span></a></span></span><span>
</span><span id="line-1028"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe (Int, StrictSig)
</span><a href="#local-6989586621680962568"><span class="hs-identifier hs-var">mb_str</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1029"></span><span>      </span><span class="annot"><span class="annottext">Maybe (Int, StrictSig)
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962570"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-1030"></span><span>      </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680962567"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962567"><span class="hs-identifier hs-var">arity</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962566"><span class="annot"><span class="annottext">StrictSig
</span><a href="#local-6989586621680962566"><span class="hs-identifier hs-var">sig</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962570"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Int -&gt; Id
</span><a href="GHC.Types.Id.html#setIdArity"><span class="hs-operator hs-var">`setIdArity`</span></a></span><span>      </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962567"><span class="hs-identifier hs-var">arity</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962569"><span class="hs-identifier hs-var">n_extra</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1031"></span><span>                              </span><span class="annot"><span class="annottext">Id -&gt; StrictSig -&gt; Id
</span><a href="GHC.Types.Id.html#setIdStrictness"><span class="hs-operator hs-var">`setIdStrictness`</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; StrictSig -&gt; StrictSig
</span><a href="GHC.Types.Demand.html#prependArgsStrictSig"><span class="hs-identifier hs-var">prependArgsStrictSig</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962569"><span class="hs-identifier hs-var">n_extra</span></a></span><span> </span><span class="annot"><span class="annottext">StrictSig
</span><a href="#local-6989586621680962566"><span class="hs-identifier hs-var">sig</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1032"></span><span>                              </span><span class="annot"><span class="annottext">Id -&gt; CprSig -&gt; Id
</span><a href="GHC.Types.Id.html#setIdCprInfo"><span class="hs-operator hs-var">`setIdCprInfo`</span></a></span><span>    </span><span class="annot"><span class="annottext">Int -&gt; CprResult -&gt; CprSig
</span><a href="GHC.Types.Cpr.html#mkCprSig"><span class="hs-identifier hs-var">mkCprSig</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962567"><span class="hs-identifier hs-var">arity</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962569"><span class="hs-identifier hs-var">n_extra</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CprResult
</span><a href="GHC.Types.Cpr.html#botCpr"><span class="hs-identifier hs-var">botCpr</span></a></span><span>
</span><span id="line-1033"></span><span>
</span><span id="line-1034"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#notWorthFloating"><span class="hs-identifier hs-type">notWorthFloating</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1035"></span><span class="hs-comment">-- Returns True if the expression would be replaced by</span><span>
</span><span id="line-1036"></span><span class="hs-comment">-- something bigger than it is now.  For example:</span><span>
</span><span id="line-1037"></span><span class="hs-comment">--   abs_vars = tvars only:  return True if e is trivial,</span><span>
</span><span id="line-1038"></span><span class="hs-comment">--                           but False for anything bigger</span><span>
</span><span id="line-1039"></span><span class="hs-comment">--   abs_vars = [x] (an Id): return True for trivial, or an application (f x)</span><span>
</span><span id="line-1040"></span><span class="hs-comment">--                           but False for (f x x)</span><span>
</span><span id="line-1041"></span><span class="hs-comment">--</span><span>
</span><span id="line-1042"></span><span class="hs-comment">-- One big goal is that floating should be idempotent.  Eg if</span><span>
</span><span id="line-1043"></span><span class="hs-comment">-- we replace e with (lvl79 x y) and then run FloatOut again, don't want</span><span>
</span><span id="line-1044"></span><span class="hs-comment">-- to replace (lvl79 x y) with (lvl83 x y)!</span><span>
</span><span id="line-1045"></span><span>
</span><span id="line-1046"></span><span id="notWorthFloating"><span class="annot"><span class="annottext">notWorthFloating :: Expr Id -&gt; [Id] -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#notWorthFloating"><span class="hs-identifier hs-var hs-var">notWorthFloating</span></a></span></span><span> </span><span id="local-6989586621680962561"><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621680962561"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span id="local-6989586621680962560"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962560"><span class="hs-identifier hs-var">abs_vars</span></a></span></span><span>
</span><span id="line-1047"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Expr Id -&gt; Int -&gt; Bool
forall {a} {b}. (Ord a, Num a) =&gt; Expr b -&gt; a -&gt; Bool
</span><a href="#local-6989586621680962559"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621680962561"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Id -&gt; Bool) -&gt; [Id] -&gt; Int
forall a. (a -&gt; Bool) -&gt; [a] -&gt; Int
</span><a href="GHC.Utils.Misc.html#count"><span class="hs-identifier hs-var">count</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isId"><span class="hs-identifier hs-var">isId</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962560"><span class="hs-identifier hs-var">abs_vars</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1048"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1049"></span><span>    </span><span id="local-6989586621680962559"><span class="annot"><span class="annottext">go :: Expr b -&gt; a -&gt; Bool
</span><a href="#local-6989586621680962559"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621680962546"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680962546"><span class="hs-identifier hs-var">n</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680962546"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; a -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;=</span></span><span> </span><span class="annot"><span class="annottext">a
</span><span class="hs-number">0</span></span><span>
</span><span id="line-1050"></span><span>    </span><span class="annot"><a href="#local-6989586621680962559"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Lit"><span class="hs-identifier hs-type">Lit</span></a></span><span> </span><span id="local-6989586621680962545"><span class="annot"><span class="annottext">Literal
</span><a href="#local-6989586621680962545"><span class="hs-identifier hs-var">lit</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680962544"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680962544"><span class="hs-identifier hs-var">n</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">n</span><span class="hs-operator">==</span><span class="hs-number">0</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-1051"></span><span>                       </span><span class="annot"><span class="annottext">Literal -&gt; Bool
</span><a href="GHC.Types.Literal.html#litIsTrivial"><span class="hs-identifier hs-var">litIsTrivial</span></a></span><span> </span><span class="annot"><span class="annottext">Literal
</span><a href="#local-6989586621680962545"><span class="hs-identifier hs-var">lit</span></a></span><span>   </span><span class="hs-comment">-- Note [Floating literals]</span><span>
</span><span id="line-1052"></span><span>    </span><span class="annot"><a href="#local-6989586621680962559"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Tick"><span class="hs-identifier hs-type">Tick</span></a></span><span> </span><span id="local-6989586621680962541"><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621680962541"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span id="local-6989586621680962540"><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680962540"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680962539"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680962539"><span class="hs-identifier hs-var">n</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tickish Id -&gt; Bool
forall id. Tickish id -&gt; Bool
</span><a href="GHC.Core.html#tickishIsCode"><span class="hs-identifier hs-var">tickishIsCode</span></a></span><span> </span><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621680962541"><span class="hs-identifier hs-var">t</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Expr b -&gt; a -&gt; Bool
</span><a href="#local-6989586621680962559"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680962540"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680962539"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-1053"></span><span>    </span><span class="annot"><a href="#local-6989586621680962559"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Cast"><span class="hs-identifier hs-type">Cast</span></a></span><span> </span><span id="local-6989586621680962537"><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680962537"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>  </span><span id="local-6989586621680962536"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680962536"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Expr b -&gt; a -&gt; Bool
</span><a href="#local-6989586621680962559"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680962537"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680962536"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-1054"></span><span>    </span><span class="annot"><a href="#local-6989586621680962559"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#App"><span class="hs-identifier hs-type">App</span></a></span><span> </span><span id="local-6989586621680962535"><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680962535"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span id="local-6989586621680962534"><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680962534"><span class="hs-identifier hs-var">arg</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680962533"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680962533"><span class="hs-identifier hs-var">n</span></a></span></span><span>
</span><span id="line-1055"></span><span>       </span><span class="hs-comment">-- See Note [Floating applications to coercions]</span><span>
</span><span id="line-1056"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Core.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680962534"><span class="hs-identifier hs-var">arg</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Expr b -&gt; a -&gt; Bool
</span><a href="#local-6989586621680962559"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680962535"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680962533"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-1057"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680962533"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">a -&gt; a -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span class="annot"><span class="annottext">a
</span><span class="hs-number">0</span></span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1058"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Expr b -&gt; Bool
forall b. Expr b -&gt; Bool
</span><a href="#local-6989586621680962532"><span class="hs-identifier hs-var">is_triv</span></a></span><span> </span><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680962534"><span class="hs-identifier hs-var">arg</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Expr b -&gt; a -&gt; Bool
</span><a href="#local-6989586621680962559"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680962535"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680962533"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">a -&gt; a -&gt; a
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">a
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-1059"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1060"></span><span>    </span><span class="annot"><a href="#local-6989586621680962559"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Expr b
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">a
</span><span class="hs-identifier">_</span></span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1061"></span><span>
</span><span id="line-1062"></span><span>    </span><span id="local-6989586621680962532"><span class="annot"><span class="annottext">is_triv :: Expr b -&gt; Bool
</span><a href="#local-6989586621680962532"><span class="hs-identifier hs-var hs-var">is_triv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Lit"><span class="hs-identifier hs-type">Lit</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>        </span><span class="hs-comment">-- Treat all literals as trivial</span><span>
</span><span id="line-1063"></span><span>    </span><span class="annot"><a href="#local-6989586621680962532"><span class="hs-identifier hs-var">is_triv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>        </span><span class="hs-comment">-- (ie not worth floating)</span><span>
</span><span id="line-1064"></span><span>    </span><span class="annot"><a href="#local-6989586621680962532"><span class="hs-identifier hs-var">is_triv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Cast"><span class="hs-identifier hs-type">Cast</span></a></span><span> </span><span id="local-6989586621680962531"><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680962531"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Expr b -&gt; Bool
</span><a href="#local-6989586621680962532"><span class="hs-identifier hs-var">is_triv</span></a></span><span> </span><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680962531"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-1065"></span><span>    </span><span class="annot"><a href="#local-6989586621680962532"><span class="hs-identifier hs-var">is_triv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#App"><span class="hs-identifier hs-type">App</span></a></span><span> </span><span id="local-6989586621680962530"><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680962530"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span class="hs-special">)</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Expr b -&gt; Bool
</span><a href="#local-6989586621680962532"><span class="hs-identifier hs-var">is_triv</span></a></span><span> </span><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680962530"><span class="hs-identifier hs-var">e</span></a></span><span>   </span><span class="hs-comment">-- See Note [Floating applications to coercions]</span><span>
</span><span id="line-1066"></span><span>    </span><span class="annot"><a href="#local-6989586621680962532"><span class="hs-identifier hs-var">is_triv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Tick"><span class="hs-identifier hs-type">Tick</span></a></span><span> </span><span id="local-6989586621680962529"><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621680962529"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span id="local-6989586621680962528"><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680962528"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tickish Id -&gt; Bool
forall id. Tickish id -&gt; Bool
</span><a href="GHC.Core.html#tickishIsCode"><span class="hs-identifier hs-var">tickishIsCode</span></a></span><span> </span><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621680962529"><span class="hs-identifier hs-var">t</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Expr b -&gt; Bool
</span><a href="#local-6989586621680962532"><span class="hs-identifier hs-var">is_triv</span></a></span><span> </span><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680962528"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-1067"></span><span>    </span><span class="annot"><a href="#local-6989586621680962532"><span class="hs-identifier hs-var">is_triv</span></a></span><span> </span><span class="annot"><span class="annottext">Expr b
</span><span class="hs-identifier">_</span></span><span>                     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1068"></span><span>
</span><span id="line-1069"></span><span class="hs-comment">{-
Note [Floating literals]
~~~~~~~~~~~~~~~~~~~~~~~~
It's important to float Integer literals, so that they get shared,
rather than being allocated every time round the loop.
Hence the litIsTrivial.

Ditto literal strings (LitString), which we'd like to float to top
level, which is now possible.

Note [Floating applications to coercions]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We don&#8217;t float out variables applied only to type arguments, since the
extra binding would be pointless: type arguments are completely erased.
But *coercion* arguments aren&#8217;t (see Note [Coercion tokens] in
&quot;GHC.CoreToStg&quot; and Note [Count coercion arguments in boring contexts] in
&quot;GHC.Core.Unfold&quot;), so we still want to float out variables applied only to
coercion arguments.

Note [Escaping a value lambda]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We want to float even cheap expressions out of value lambdas,
because that saves allocation.  Consider
        f = \x.  .. (\y.e) ...
Then we'd like to avoid allocating the (\y.e) every time we call f,
(assuming e does not mention x). An example where this really makes a
difference is simplrun009.

Another reason it's good is because it makes SpecContr fire on functions.
Consider
        f = \x. ....(f (\y.e))....
After floating we get
        lvl = \y.e
        f = \x. ....(f lvl)...
and that is much easier for SpecConstr to generate a robust
specialisation for.

However, if we are wrapping the thing in extra value lambdas (in
abs_vars), then nothing is saved.  E.g.
        f = \xyz. ...(e1[y],e2)....
If we float
        lvl = \y. (e1[y],e2)
        f = \xyz. ...(lvl y)...
we have saved nothing: one pair will still be allocated for each
call of 'f'.  Hence the (not float_is_lam) in float_me.


************************************************************************
*                                                                      *
\subsection{Bindings}
*                                                                      *
************************************************************************

The binding stuff works for top level too.
-}</span><span>
</span><span id="line-1124"></span><span>
</span><span id="line-1125"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#lvlBind"><span class="hs-identifier hs-type">lvlBind</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span>
</span><span id="line-1126"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.FVs.html#CoreBindWithFVs"><span class="hs-identifier hs-type">CoreBindWithFVs</span></a></span><span>
</span><span id="line-1127"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LvlM"><span class="hs-identifier hs-type">LvlM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelledBind"><span class="hs-identifier hs-type">LevelledBind</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1128"></span><span>
</span><span id="line-1129"></span><span id="lvlBind"><span class="annot"><span class="annottext">lvlBind :: LevelEnv -&gt; AnnBind Id FVAnn -&gt; LvlM (LevelledBind, LevelEnv)
</span><a href="GHC.Core.Opt.SetLevels.html#lvlBind"><span class="hs-identifier hs-var hs-var">lvlBind</span></a></span></span><span> </span><span id="local-6989586621680962526"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962526"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#AnnNonRec"><span class="hs-identifier hs-type">AnnNonRec</span></a></span><span> </span><span id="local-6989586621680962524"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962524"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621680962523"><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962523"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1130"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isTyVar"><span class="hs-identifier hs-var">isTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962524"><span class="hs-identifier hs-var">bndr</span></a></span><span>    </span><span class="hs-comment">-- Don't do anything for TyVar binders</span><span>
</span><span id="line-1131"></span><span>                    </span><span class="hs-comment">--   (simplifier gets rid of them pronto)</span><span>
</span><span id="line-1132"></span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isCoVar"><span class="hs-identifier hs-var">isCoVar</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962524"><span class="hs-identifier hs-var">bndr</span></a></span><span>   </span><span class="hs-comment">-- Difficult to fix up CoVar occurrences (see extendPolyLvlEnv)</span><span>
</span><span id="line-1133"></span><span>                    </span><span class="hs-comment">-- so we will ignore this case for now</span><span>
</span><span id="line-1134"></span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; Level -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#profitableFloat"><span class="hs-identifier hs-var">profitableFloat</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962526"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962519"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1135"></span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Level -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#isTopLvl"><span class="hs-identifier hs-var">isTopLvl</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962519"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Expr Id -&gt; Type -&gt; Bool
</span><a href="GHC.Core.Utils.html#exprIsTopLevelBindable"><span class="hs-identifier hs-var">exprIsTopLevelBindable</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621680962518"><span class="hs-identifier hs-var">deann_rhs</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680962517"><span class="hs-identifier hs-var">bndr_ty</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1136"></span><span>          </span><span class="hs-comment">-- We can't float an unlifted binding to top level (except</span><span>
</span><span id="line-1137"></span><span>          </span><span class="hs-comment">-- literal strings), so we don't float it at all.  It's a</span><span>
</span><span id="line-1138"></span><span>          </span><span class="hs-comment">-- bit brutal, but unlifted bindings aren't expensive either</span><span>
</span><span id="line-1139"></span><span>
</span><span id="line-1140"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- No float</span><span>
</span><span id="line-1141"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680962516"><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962516"><span class="hs-identifier hs-var">rhs'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LevelEnv
-&gt; RecFlag
-&gt; Bool
-&gt; Maybe Int
-&gt; CoreExprWithFVs
-&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlRhs"><span class="hs-identifier hs-var">lvlRhs</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962526"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="GHC.Types.Basic.html#NonRecursive"><span class="hs-identifier hs-var">NonRecursive</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962515"><span class="hs-identifier hs-var">is_bot</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621680962514"><span class="hs-identifier hs-var">mb_join_arity</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962523"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-1142"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span>  </span><span id="local-6989586621680962513"><span class="annot"><span class="annottext">bind_lvl :: Level
</span><a href="#local-6989586621680962513"><span class="hs-identifier hs-var hs-var">bind_lvl</span></a></span></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#incMinorLvl"><span class="hs-identifier hs-var">incMinorLvl</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#le_ctxt_lvl"><span class="hs-identifier hs-var hs-var">le_ctxt_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962526"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1143"></span><span>              </span><span class="hs-special">(</span><span id="local-6989586621680962512"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962512"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span id="local-6989586621680962511"><span class="annot"><span class="annottext">LevelledBndr
</span><a href="#local-6989586621680962511"><span class="hs-identifier hs-var">bndr'</span></a></span></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RecFlag -&gt; LevelEnv -&gt; Level -&gt; [Id] -&gt; (LevelEnv, [LevelledBndr])
</span><a href="GHC.Core.Opt.SetLevels.html#substAndLvlBndrs"><span class="hs-identifier hs-var">substAndLvlBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="GHC.Types.Basic.html#NonRecursive"><span class="hs-identifier hs-var">NonRecursive</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962526"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962513"><span class="hs-identifier hs-var">bind_lvl</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962524"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1144"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(LevelledBind, LevelEnv) -&gt; LvlM (LevelledBind, LevelEnv)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelledBndr -&gt; LevelledExpr -&gt; LevelledBind
forall b. b -&gt; Expr b -&gt; Bind b
</span><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-var">NonRec</span></a></span><span> </span><span class="annot"><span class="annottext">LevelledBndr
</span><a href="#local-6989586621680962511"><span class="hs-identifier hs-var">bndr'</span></a></span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962516"><span class="hs-identifier hs-var">rhs'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962512"><span class="hs-identifier hs-var">env'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1145"></span><span>
</span><span id="line-1146"></span><span>  </span><span class="hs-comment">-- Otherwise we are going to float</span><span>
</span><span id="line-1147"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962509"><span class="hs-identifier hs-var">abs_vars</span></a></span><span>
</span><span id="line-1148"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span>  </span><span class="hs-comment">-- No type abstraction; clone existing binder</span><span>
</span><span id="line-1149"></span><span>         </span><span id="local-6989586621680962508"><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962508"><span class="hs-identifier hs-var">rhs'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Id]
-&gt; Level
-&gt; LevelEnv
-&gt; RecFlag
-&gt; Bool
-&gt; Maybe Int
-&gt; CoreExprWithFVs
-&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlFloatRhs"><span class="hs-identifier hs-var">lvlFloatRhs</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962519"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962526"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="GHC.Types.Basic.html#NonRecursive"><span class="hs-identifier hs-var">NonRecursive</span></a></span><span>
</span><span id="line-1150"></span><span>                             </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962515"><span class="hs-identifier hs-var">is_bot</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621680962514"><span class="hs-identifier hs-var">mb_join_arity</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962523"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-1151"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680962507"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962507"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span id="local-6989586621680962506"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962506"><span class="hs-identifier hs-var">bndr'</span></a></span></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RecFlag -&gt; LevelEnv -&gt; Level -&gt; [Id] -&gt; LvlM (LevelEnv, [Id])
</span><a href="GHC.Core.Opt.SetLevels.html#cloneLetVars"><span class="hs-identifier hs-var">cloneLetVars</span></a></span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="GHC.Types.Basic.html#NonRecursive"><span class="hs-identifier hs-var">NonRecursive</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962526"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962519"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962524"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1152"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680962504"><span class="annot"><span class="annottext">bndr2 :: Id
</span><a href="#local-6989586621680962504"><span class="hs-identifier hs-var hs-var">bndr2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Int -&gt; Maybe (Int, StrictSig) -&gt; Id
</span><a href="GHC.Core.Opt.SetLevels.html#annotateBotStr"><span class="hs-identifier hs-var">annotateBotStr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962506"><span class="hs-identifier hs-var">bndr'</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Maybe (Int, StrictSig)
</span><a href="#local-6989586621680962503"><span class="hs-identifier hs-var">mb_bot_str</span></a></span><span>
</span><span id="line-1153"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(LevelledBind, LevelEnv) -&gt; LvlM (LevelledBind, LevelEnv)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelledBndr -&gt; LevelledExpr -&gt; LevelledBind
forall b. b -&gt; Expr b -&gt; Bind b
</span><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-var">NonRec</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; FloatSpec -&gt; LevelledBndr
forall t. Id -&gt; t -&gt; TaggedBndr t
</span><a href="GHC.Core.html#TB"><span class="hs-identifier hs-var">TB</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962504"><span class="hs-identifier hs-var">bndr2</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Level -&gt; FloatSpec
</span><a href="GHC.Core.Opt.SetLevels.html#FloatMe"><span class="hs-identifier hs-var">FloatMe</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962519"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962508"><span class="hs-identifier hs-var">rhs'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962507"><span class="hs-identifier hs-var">env'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1154"></span><span>
</span><span id="line-1155"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1156"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span>  </span><span class="hs-comment">-- Yes, type abstraction; create a new binder, extend substitution, etc</span><span>
</span><span id="line-1157"></span><span>         </span><span id="local-6989586621680962502"><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962502"><span class="hs-identifier hs-var">rhs'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Id]
-&gt; Level
-&gt; LevelEnv
-&gt; RecFlag
-&gt; Bool
-&gt; Maybe Int
-&gt; CoreExprWithFVs
-&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlFloatRhs"><span class="hs-identifier hs-var">lvlFloatRhs</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962509"><span class="hs-identifier hs-var">abs_vars</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962519"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962526"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="GHC.Types.Basic.html#NonRecursive"><span class="hs-identifier hs-var">NonRecursive</span></a></span><span>
</span><span id="line-1158"></span><span>                             </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962515"><span class="hs-identifier hs-var">is_bot</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621680962514"><span class="hs-identifier hs-var">mb_join_arity</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962523"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-1159"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680962501"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962501"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span id="local-6989586621680962500"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962500"><span class="hs-identifier hs-var">bndr'</span></a></span></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Level -&gt; LevelEnv -&gt; [Id] -&gt; [Id] -&gt; LvlM (LevelEnv, [Id])
</span><a href="GHC.Core.Opt.SetLevels.html#newPolyBndrs"><span class="hs-identifier hs-var">newPolyBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962519"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962526"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962509"><span class="hs-identifier hs-var">abs_vars</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962524"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1160"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680962498"><span class="annot"><span class="annottext">bndr2 :: Id
</span><a href="#local-6989586621680962498"><span class="hs-identifier hs-var hs-var">bndr2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Int -&gt; Maybe (Int, StrictSig) -&gt; Id
</span><a href="GHC.Core.Opt.SetLevels.html#annotateBotStr"><span class="hs-identifier hs-var">annotateBotStr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962500"><span class="hs-identifier hs-var">bndr'</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962497"><span class="hs-identifier hs-var">n_extra</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (Int, StrictSig)
</span><a href="#local-6989586621680962503"><span class="hs-identifier hs-var">mb_bot_str</span></a></span><span>
</span><span id="line-1161"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(LevelledBind, LevelEnv) -&gt; LvlM (LevelledBind, LevelEnv)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelledBndr -&gt; LevelledExpr -&gt; LevelledBind
forall b. b -&gt; Expr b -&gt; Bind b
</span><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-var">NonRec</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; FloatSpec -&gt; LevelledBndr
forall t. Id -&gt; t -&gt; TaggedBndr t
</span><a href="GHC.Core.html#TB"><span class="hs-identifier hs-var">TB</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962498"><span class="hs-identifier hs-var">bndr2</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Level -&gt; FloatSpec
</span><a href="GHC.Core.Opt.SetLevels.html#FloatMe"><span class="hs-identifier hs-var">FloatMe</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962519"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962502"><span class="hs-identifier hs-var">rhs'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962501"><span class="hs-identifier hs-var">env'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1162"></span><span>
</span><span id="line-1163"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1164"></span><span>    </span><span id="local-6989586621680962517"><span class="annot"><span class="annottext">bndr_ty :: Type
</span><a href="#local-6989586621680962517"><span class="hs-identifier hs-var hs-var">bndr_ty</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962524"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-1165"></span><span>    </span><span id="local-6989586621680962495"><span class="annot"><span class="annottext">ty_fvs :: TyCoVarSet
</span><a href="#local-6989586621680962495"><span class="hs-identifier hs-var hs-var">ty_fvs</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; TyCoVarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfType"><span class="hs-identifier hs-var">tyCoVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680962517"><span class="hs-identifier hs-var">bndr_ty</span></a></span><span>
</span><span id="line-1166"></span><span>    </span><span id="local-6989586621680962494"><span class="annot"><span class="annottext">rhs_fvs :: FVAnn
</span><a href="#local-6989586621680962494"><span class="hs-identifier hs-var hs-var">rhs_fvs</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs -&gt; FVAnn
</span><a href="GHC.Core.FVs.html#freeVarsOf"><span class="hs-identifier hs-var">freeVarsOf</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962523"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-1167"></span><span>    </span><span id="local-6989586621680962493"><span class="annot"><span class="annottext">bind_fvs :: FVAnn
</span><a href="#local-6989586621680962493"><span class="hs-identifier hs-var hs-var">bind_fvs</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FVAnn
</span><a href="#local-6989586621680962494"><span class="hs-identifier hs-var">rhs_fvs</span></a></span><span> </span><span class="annot"><span class="annottext">FVAnn -&gt; FVAnn -&gt; FVAnn
</span><a href="GHC.Types.Var.Set.html#unionDVarSet"><span class="hs-operator hs-var">`unionDVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; FVAnn
</span><a href="GHC.Core.FVs.html#dIdFreeVars"><span class="hs-identifier hs-var">dIdFreeVars</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962524"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-1168"></span><span>    </span><span id="local-6989586621680962509"><span class="annot"><span class="annottext">abs_vars :: [Id]
</span><a href="#local-6989586621680962509"><span class="hs-identifier hs-var hs-var">abs_vars</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level -&gt; LevelEnv -&gt; FVAnn -&gt; [Id]
</span><a href="GHC.Core.Opt.SetLevels.html#abstractVars"><span class="hs-identifier hs-var">abstractVars</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962519"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962526"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">FVAnn
</span><a href="#local-6989586621680962493"><span class="hs-identifier hs-var">bind_fvs</span></a></span><span>
</span><span id="line-1169"></span><span>    </span><span id="local-6989586621680962519"><span class="annot"><span class="annottext">dest_lvl :: Level
</span><a href="#local-6989586621680962519"><span class="hs-identifier hs-var hs-var">dest_lvl</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; FVAnn -&gt; TyCoVarSet -&gt; Bool -&gt; Bool -&gt; Bool -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#destLevel"><span class="hs-identifier hs-var">destLevel</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962526"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">FVAnn
</span><a href="#local-6989586621680962493"><span class="hs-identifier hs-var">bind_fvs</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVarSet
</span><a href="#local-6989586621680962495"><span class="hs-identifier hs-var">ty_fvs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExprWithFVs -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#isFunction"><span class="hs-identifier hs-var">isFunction</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962523"><span class="hs-identifier hs-var">rhs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962515"><span class="hs-identifier hs-var">is_bot</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962490"><span class="hs-identifier hs-var">is_join</span></a></span><span>
</span><span id="line-1170"></span><span>
</span><span id="line-1171"></span><span>    </span><span id="local-6989586621680962518"><span class="annot"><span class="annottext">deann_rhs :: Expr Id
</span><a href="#local-6989586621680962518"><span class="hs-identifier hs-var hs-var">deann_rhs</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs -&gt; Expr Id
forall bndr annot. AnnExpr bndr annot -&gt; Expr bndr
</span><a href="GHC.Core.html#deAnnotate"><span class="hs-identifier hs-var">deAnnotate</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962523"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-1172"></span><span>    </span><span id="local-6989586621680962503"><span class="annot"><span class="annottext">mb_bot_str :: Maybe (Int, StrictSig)
</span><a href="#local-6989586621680962503"><span class="hs-identifier hs-var hs-var">mb_bot_str</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Expr Id -&gt; Maybe (Int, StrictSig)
</span><a href="GHC.Core.Opt.Arity.html#exprBotStrictness_maybe"><span class="hs-identifier hs-var">exprBotStrictness_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621680962518"><span class="hs-identifier hs-var">deann_rhs</span></a></span><span>
</span><span id="line-1173"></span><span>    </span><span id="local-6989586621680962515"><span class="annot"><span class="annottext">is_bot :: Bool
</span><a href="#local-6989586621680962515"><span class="hs-identifier hs-var hs-var">is_bot</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe (Int, StrictSig) -&gt; Bool
forall a. Maybe a -&gt; Bool
</span><a href="../../base/src/Data.Maybe.html#isJust"><span class="hs-identifier hs-var">isJust</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (Int, StrictSig)
</span><a href="#local-6989586621680962503"><span class="hs-identifier hs-var">mb_bot_str</span></a></span><span>
</span><span id="line-1174"></span><span>        </span><span class="hs-comment">-- NB: not isBottomThunk!  See Note [Bottoming floats] point (3)</span><span>
</span><span id="line-1175"></span><span>
</span><span id="line-1176"></span><span>    </span><span id="local-6989586621680962497"><span class="annot"><span class="annottext">n_extra :: Int
</span><a href="#local-6989586621680962497"><span class="hs-identifier hs-var hs-var">n_extra</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Bool) -&gt; [Id] -&gt; Int
forall a. (a -&gt; Bool) -&gt; [a] -&gt; Int
</span><a href="GHC.Utils.Misc.html#count"><span class="hs-identifier hs-var">count</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isId"><span class="hs-identifier hs-var">isId</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962509"><span class="hs-identifier hs-var">abs_vars</span></a></span><span>
</span><span id="line-1177"></span><span>    </span><span id="local-6989586621680962514"><span class="annot"><span class="annottext">mb_join_arity :: Maybe Int
</span><a href="#local-6989586621680962514"><span class="hs-identifier hs-var hs-var">mb_join_arity</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Maybe Int
</span><a href="GHC.Types.Id.html#isJoinId_maybe"><span class="hs-identifier hs-var">isJoinId_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962524"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-1178"></span><span>    </span><span id="local-6989586621680962490"><span class="annot"><span class="annottext">is_join :: Bool
</span><a href="#local-6989586621680962490"><span class="hs-identifier hs-var hs-var">is_join</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Int -&gt; Bool
forall a. Maybe a -&gt; Bool
</span><a href="../../base/src/Data.Maybe.html#isJust"><span class="hs-identifier hs-var">isJust</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621680962514"><span class="hs-identifier hs-var">mb_join_arity</span></a></span><span>
</span><span id="line-1179"></span><span>
</span><span id="line-1180"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#lvlBind"><span class="hs-identifier hs-var">lvlBind</span></a></span><span> </span><span id="local-6989586621680962488"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962488"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#AnnRec"><span class="hs-identifier hs-type">AnnRec</span></a></span><span> </span><span id="local-6989586621680962486"><span class="annot"><span class="annottext">[(Id, CoreExprWithFVs)]
</span><a href="#local-6989586621680962486"><span class="hs-identifier hs-var">pairs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1181"></span><span>  </span><span class="hs-glyph">|</span><span>  </span><span class="annot"><span class="annottext">LevelEnv -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#floatTopLvlOnly"><span class="hs-identifier hs-var">floatTopLvlOnly</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962488"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Level -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#isTopLvl"><span class="hs-identifier hs-var">isTopLvl</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962485"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1182"></span><span>         </span><span class="hs-comment">-- Only floating to the top level is allowed.</span><span>
</span><span id="line-1183"></span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; Level -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#profitableFloat"><span class="hs-identifier hs-var">profitableFloat</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962488"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962485"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1184"></span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Level -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#isTopLvl"><span class="hs-identifier hs-var">isTopLvl</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962485"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Bool) -&gt; [Id] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#any"><span class="hs-identifier hs-var">any</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.Core.Type.html#mightBeUnliftedType"><span class="hs-identifier hs-var">mightBeUnliftedType</span></a></span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Bool) -&gt; (Id -&gt; Type) -&gt; Id -&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962483"><span class="hs-identifier hs-var">bndrs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1185"></span><span>       </span><span class="hs-comment">-- This mightBeUnliftedType stuff is the same test as in the non-rec case</span><span>
</span><span id="line-1186"></span><span>       </span><span class="hs-comment">-- You might wonder whether we can have a recursive binding for</span><span>
</span><span id="line-1187"></span><span>       </span><span class="hs-comment">-- an unlifted value -- but we can if it's a /join binding/ (#16978)</span><span>
</span><span id="line-1188"></span><span>       </span><span class="hs-comment">-- (Ultimately I think we should not use GHC.Core.Opt.SetLevels to</span><span>
</span><span id="line-1189"></span><span>       </span><span class="hs-comment">-- float join bindings at all, but that's another story.)</span><span>
</span><span id="line-1190"></span><span>  </span><span class="hs-glyph">=</span><span>    </span><span class="hs-comment">-- No float</span><span>
</span><span id="line-1191"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680962482"><span class="annot"><span class="annottext">bind_lvl :: Level
</span><a href="#local-6989586621680962482"><span class="hs-identifier hs-var hs-var">bind_lvl</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#incMinorLvl"><span class="hs-identifier hs-var">incMinorLvl</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#le_ctxt_lvl"><span class="hs-identifier hs-var hs-var">le_ctxt_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962488"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1192"></span><span>             </span><span class="hs-special">(</span><span id="local-6989586621680962481"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962481"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962480"><span class="annot"><span class="annottext">[LevelledBndr]
</span><a href="#local-6989586621680962480"><span class="hs-identifier hs-var">bndrs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RecFlag -&gt; LevelEnv -&gt; Level -&gt; [Id] -&gt; (LevelEnv, [LevelledBndr])
</span><a href="GHC.Core.Opt.SetLevels.html#substAndLvlBndrs"><span class="hs-identifier hs-var">substAndLvlBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="GHC.Types.Basic.html#Recursive"><span class="hs-identifier hs-var">Recursive</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962488"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962482"><span class="hs-identifier hs-var">bind_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962483"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-1193"></span><span>             </span><span id="local-6989586621680962479"><span class="annot"><span class="annottext">lvl_rhs :: (Id, CoreExprWithFVs) -&gt; LvlM LevelledExpr
</span><a href="#local-6989586621680962479"><span class="hs-identifier hs-var hs-var">lvl_rhs</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680962478"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962478"><span class="hs-identifier hs-var">b</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680962477"><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962477"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelEnv
-&gt; RecFlag
-&gt; Bool
-&gt; Maybe Int
-&gt; CoreExprWithFVs
-&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlRhs"><span class="hs-identifier hs-var">lvlRhs</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962481"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="GHC.Types.Basic.html#Recursive"><span class="hs-identifier hs-var">Recursive</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962476"><span class="hs-identifier hs-var">is_bot</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Maybe Int
</span><a href="GHC.Types.Id.html#isJoinId_maybe"><span class="hs-identifier hs-var">isJoinId_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962478"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962477"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-1194"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621680962475"><span class="annot"><span class="annottext">[LevelledExpr]
</span><a href="#local-6989586621680962475"><span class="hs-identifier hs-var">rhss'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">((Id, CoreExprWithFVs) -&gt; LvlM LevelledExpr)
-&gt; [(Id, CoreExprWithFVs)] -&gt; UniqSM [LevelledExpr]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">(Id, CoreExprWithFVs) -&gt; LvlM LevelledExpr
</span><a href="#local-6989586621680962479"><span class="hs-identifier hs-var">lvl_rhs</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExprWithFVs)]
</span><a href="#local-6989586621680962486"><span class="hs-identifier hs-var">pairs</span></a></span><span>
</span><span id="line-1195"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(LevelledBind, LevelEnv) -&gt; LvlM (LevelledBind, LevelEnv)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(LevelledBndr, LevelledExpr)] -&gt; LevelledBind
forall b. [(b, Expr b)] -&gt; Bind b
</span><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-var">Rec</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[LevelledBndr]
</span><a href="#local-6989586621680962480"><span class="hs-identifier hs-var">bndrs'</span></a></span><span> </span><span class="annot"><span class="annottext">[LevelledBndr] -&gt; [LevelledExpr] -&gt; [(LevelledBndr, LevelledExpr)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-operator hs-var">`zip`</span></a></span><span> </span><span class="annot"><span class="annottext">[LevelledExpr]
</span><a href="#local-6989586621680962475"><span class="hs-identifier hs-var">rhss'</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962481"><span class="hs-identifier hs-var">env'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1196"></span><span>
</span><span id="line-1197"></span><span>  </span><span class="hs-comment">-- Otherwise we are going to float</span><span>
</span><span id="line-1198"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962474"><span class="hs-identifier hs-var">abs_vars</span></a></span><span>
</span><span id="line-1199"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680962473"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962473"><span class="hs-identifier hs-var">new_env</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962472"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962472"><span class="hs-identifier hs-var">new_bndrs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RecFlag -&gt; LevelEnv -&gt; Level -&gt; [Id] -&gt; LvlM (LevelEnv, [Id])
</span><a href="GHC.Core.Opt.SetLevels.html#cloneLetVars"><span class="hs-identifier hs-var">cloneLetVars</span></a></span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="GHC.Types.Basic.html#Recursive"><span class="hs-identifier hs-var">Recursive</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962488"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962485"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962483"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-1200"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621680962471"><span class="annot"><span class="annottext">[LevelledExpr]
</span><a href="#local-6989586621680962471"><span class="hs-identifier hs-var">new_rhss</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">((Id, CoreExprWithFVs) -&gt; LvlM LevelledExpr)
-&gt; [(Id, CoreExprWithFVs)] -&gt; UniqSM [LevelledExpr]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; (Id, CoreExprWithFVs) -&gt; LvlM LevelledExpr
</span><a href="#local-6989586621680962470"><span class="hs-identifier hs-var">do_rhs</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962473"><span class="hs-identifier hs-var">new_env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExprWithFVs)]
</span><a href="#local-6989586621680962486"><span class="hs-identifier hs-var">pairs</span></a></span><span>
</span><span id="line-1201"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(LevelledBind, LevelEnv) -&gt; LvlM (LevelledBind, LevelEnv)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">[(LevelledBndr, LevelledExpr)] -&gt; LevelledBind
forall b. [(b, Expr b)] -&gt; Bind b
</span><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-var">Rec</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><span class="annottext">Id -&gt; FloatSpec -&gt; LevelledBndr
forall t. Id -&gt; t -&gt; TaggedBndr t
</span><a href="GHC.Core.html#TB"><span class="hs-identifier hs-var">TB</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962469"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Level -&gt; FloatSpec
</span><a href="GHC.Core.Opt.SetLevels.html#FloatMe"><span class="hs-identifier hs-var">FloatMe</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962485"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621680962469"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962469"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962472"><span class="hs-identifier hs-var">new_bndrs</span></a></span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">[LevelledBndr] -&gt; [LevelledExpr] -&gt; [(LevelledBndr, LevelledExpr)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-operator hs-var">`zip`</span></a></span><span> </span><span class="annot"><span class="annottext">[LevelledExpr]
</span><a href="#local-6989586621680962471"><span class="hs-identifier hs-var">new_rhss</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1202"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962473"><span class="hs-identifier hs-var">new_env</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1203"></span><span>
</span><span id="line-1204"></span><span class="hs-comment">-- ToDo: when enabling the floatLambda stuff,</span><span>
</span><span id="line-1205"></span><span class="hs-comment">--       I think we want to stop doing this</span><span>
</span><span id="line-1206"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span id="local-6989586621680962468"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962468"><span class="hs-identifier hs-var">bndr</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680962467"><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962467"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExprWithFVs)]
</span><a href="#local-6989586621680962486"><span class="hs-identifier hs-var">pairs</span></a></span><span>
</span><span id="line-1207"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Bool) -&gt; [Id] -&gt; Int
forall a. (a -&gt; Bool) -&gt; [a] -&gt; Int
</span><a href="GHC.Utils.Misc.html#count"><span class="hs-identifier hs-var">count</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isId"><span class="hs-identifier hs-var">isId</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962474"><span class="hs-identifier hs-var">abs_vars</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span>
</span><span id="line-1208"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-comment">-- Special case for self recursion where there are</span><span>
</span><span id="line-1209"></span><span>        </span><span class="hs-comment">-- several variables carried around: build a local loop:</span><span>
</span><span id="line-1210"></span><span>        </span><span class="hs-comment">--      poly_f = \abs_vars. \lam_vars . letrec f = \lam_vars. rhs in f lam_vars</span><span>
</span><span id="line-1211"></span><span>        </span><span class="hs-comment">-- This just makes the closures a bit smaller.  If we don't do</span><span>
</span><span id="line-1212"></span><span>        </span><span class="hs-comment">-- this, allocation rises significantly on some programs</span><span>
</span><span id="line-1213"></span><span>        </span><span class="hs-comment">--</span><span>
</span><span id="line-1214"></span><span>        </span><span class="hs-comment">-- We could elaborate it for the case where there are several</span><span>
</span><span id="line-1215"></span><span>        </span><span class="hs-comment">-- mutually recursive functions, but it's quite a bit more complicated</span><span>
</span><span id="line-1216"></span><span>        </span><span class="hs-comment">--</span><span>
</span><span id="line-1217"></span><span>        </span><span class="hs-comment">-- This all seems a bit ad hoc -- sigh</span><span>
</span><span id="line-1218"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680962466"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962466"><span class="hs-identifier hs-var">rhs_env</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962465"><span class="annot"><span class="annottext">[LevelledBndr]
</span><a href="#local-6989586621680962465"><span class="hs-identifier hs-var">abs_vars_w_lvls</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Level -&gt; [Id] -&gt; (LevelEnv, [LevelledBndr])
</span><a href="GHC.Core.Opt.SetLevels.html#lvlLamBndrs"><span class="hs-identifier hs-var">lvlLamBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962488"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962485"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962474"><span class="hs-identifier hs-var">abs_vars</span></a></span><span>
</span><span id="line-1219"></span><span>        </span><span id="local-6989586621680962464"><span class="annot"><span class="annottext">rhs_lvl :: Level
</span><a href="#local-6989586621680962464"><span class="hs-identifier hs-var hs-var">rhs_lvl</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#le_ctxt_lvl"><span class="hs-identifier hs-var hs-var">le_ctxt_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962466"><span class="hs-identifier hs-var">rhs_env</span></a></span><span>
</span><span id="line-1220"></span><span>
</span><span id="line-1221"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680962463"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962463"><span class="hs-identifier hs-var">rhs_env'</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span id="local-6989586621680962462"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962462"><span class="hs-identifier hs-var">new_bndr</span></a></span></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RecFlag -&gt; LevelEnv -&gt; Level -&gt; [Id] -&gt; LvlM (LevelEnv, [Id])
</span><a href="GHC.Core.Opt.SetLevels.html#cloneLetVars"><span class="hs-identifier hs-var">cloneLetVars</span></a></span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="GHC.Types.Basic.html#Recursive"><span class="hs-identifier hs-var">Recursive</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962466"><span class="hs-identifier hs-var">rhs_env</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962464"><span class="hs-identifier hs-var">rhs_lvl</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962468"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1222"></span><span>    </span><span class="hs-keyword">let</span><span>
</span><span id="line-1223"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621680962461"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962461"><span class="hs-identifier hs-var">lam_bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962460"><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962460"><span class="hs-identifier hs-var">rhs_body</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs -&gt; ([Id], CoreExprWithFVs)
forall bndr annot.
AnnExpr bndr annot -&gt; ([bndr], AnnExpr bndr annot)
</span><a href="GHC.Core.html#collectAnnBndrs"><span class="hs-identifier hs-var">collectAnnBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962467"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-1224"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621680962459"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962459"><span class="hs-identifier hs-var">body_env1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962458"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962458"><span class="hs-identifier hs-var">lam_bndrs1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RecFlag -&gt; LevelEnv -&gt; [Id] -&gt; (LevelEnv, [Id])
</span><a href="GHC.Core.Opt.SetLevels.html#substBndrsSL"><span class="hs-identifier hs-var">substBndrsSL</span></a></span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="GHC.Types.Basic.html#NonRecursive"><span class="hs-identifier hs-var">NonRecursive</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962463"><span class="hs-identifier hs-var">rhs_env'</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962461"><span class="hs-identifier hs-var">lam_bndrs</span></a></span><span>
</span><span id="line-1225"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621680962457"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962457"><span class="hs-identifier hs-var">body_env2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962456"><span class="annot"><span class="annottext">[LevelledBndr]
</span><a href="#local-6989586621680962456"><span class="hs-identifier hs-var">lam_bndrs2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Level -&gt; [Id] -&gt; (LevelEnv, [LevelledBndr])
</span><a href="GHC.Core.Opt.SetLevels.html#lvlLamBndrs"><span class="hs-identifier hs-var">lvlLamBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962459"><span class="hs-identifier hs-var">body_env1</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962464"><span class="hs-identifier hs-var">rhs_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962458"><span class="hs-identifier hs-var">lam_bndrs1</span></a></span><span>
</span><span id="line-1226"></span><span>    </span><span id="local-6989586621680962455"><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962455"><span class="hs-identifier hs-var">new_rhs_body</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LevelEnv
-&gt; RecFlag
-&gt; Bool
-&gt; Maybe Int
-&gt; CoreExprWithFVs
-&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlRhs"><span class="hs-identifier hs-var">lvlRhs</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962457"><span class="hs-identifier hs-var">body_env2</span></a></span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="GHC.Types.Basic.html#Recursive"><span class="hs-identifier hs-var">Recursive</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962476"><span class="hs-identifier hs-var">is_bot</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Maybe Int
</span><a href="#local-6989586621680962454"><span class="hs-identifier hs-var">get_join</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962468"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962460"><span class="hs-identifier hs-var">rhs_body</span></a></span><span>
</span><span id="line-1227"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680962453"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962453"><span class="hs-identifier hs-var">poly_env</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span id="local-6989586621680962452"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962452"><span class="hs-identifier hs-var">poly_bndr</span></a></span></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Level -&gt; LevelEnv -&gt; [Id] -&gt; [Id] -&gt; LvlM (LevelEnv, [Id])
</span><a href="GHC.Core.Opt.SetLevels.html#newPolyBndrs"><span class="hs-identifier hs-var">newPolyBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962485"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962488"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962474"><span class="hs-identifier hs-var">abs_vars</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962468"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1228"></span><span>    </span><span class="annot"><span class="annottext">(LevelledBind, LevelEnv) -&gt; LvlM (LevelledBind, LevelEnv)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(LevelledBndr, LevelledExpr)] -&gt; LevelledBind
forall b. [(b, Expr b)] -&gt; Bind b
</span><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-var">Rec</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; FloatSpec -&gt; LevelledBndr
forall t. Id -&gt; t -&gt; TaggedBndr t
</span><a href="GHC.Core.html#TB"><span class="hs-identifier hs-var">TB</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962452"><span class="hs-identifier hs-var">poly_bndr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Level -&gt; FloatSpec
</span><a href="GHC.Core.Opt.SetLevels.html#FloatMe"><span class="hs-identifier hs-var">FloatMe</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962485"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1229"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[LevelledBndr] -&gt; LevelledExpr -&gt; LevelledExpr
forall b. [b] -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#mkLams"><span class="hs-identifier hs-var">mkLams</span></a></span><span> </span><span class="annot"><span class="annottext">[LevelledBndr]
</span><a href="#local-6989586621680962465"><span class="hs-identifier hs-var">abs_vars_w_lvls</span></a></span><span> </span><span class="annot"><span class="annottext">(LevelledExpr -&gt; LevelledExpr) -&gt; LevelledExpr -&gt; LevelledExpr
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1230"></span><span>                   </span><span class="annot"><span class="annottext">[LevelledBndr] -&gt; LevelledExpr -&gt; LevelledExpr
forall b. [b] -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#mkLams"><span class="hs-identifier hs-var">mkLams</span></a></span><span> </span><span class="annot"><span class="annottext">[LevelledBndr]
</span><a href="#local-6989586621680962456"><span class="hs-identifier hs-var">lam_bndrs2</span></a></span><span> </span><span class="annot"><span class="annottext">(LevelledExpr -&gt; LevelledExpr) -&gt; LevelledExpr -&gt; LevelledExpr
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1231"></span><span>                   </span><span class="annot"><span class="annottext">LevelledBind -&gt; LevelledExpr -&gt; LevelledExpr
forall b. Bind b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Let"><span class="hs-identifier hs-var">Let</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(LevelledBndr, LevelledExpr)] -&gt; LevelledBind
forall b. [(b, Expr b)] -&gt; Bind b
</span><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-var">Rec</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">Id -&gt; FloatSpec -&gt; LevelledBndr
forall t. Id -&gt; t -&gt; TaggedBndr t
</span><a href="GHC.Core.html#TB"><span class="hs-identifier hs-var">TB</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962462"><span class="hs-identifier hs-var">new_bndr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Level -&gt; FloatSpec
</span><a href="GHC.Core.Opt.SetLevels.html#StayPut"><span class="hs-identifier hs-var">StayPut</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962464"><span class="hs-identifier hs-var">rhs_lvl</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1232"></span><span>                             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[LevelledBndr] -&gt; LevelledExpr -&gt; LevelledExpr
forall b. [b] -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#mkLams"><span class="hs-identifier hs-var">mkLams</span></a></span><span> </span><span class="annot"><span class="annottext">[LevelledBndr]
</span><a href="#local-6989586621680962456"><span class="hs-identifier hs-var">lam_bndrs2</span></a></span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962455"><span class="hs-identifier hs-var">new_rhs_body</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1233"></span><span>                       </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelledExpr -&gt; [Id] -&gt; LevelledExpr
forall b. Expr b -&gt; [Id] -&gt; Expr b
</span><a href="GHC.Core.html#mkVarApps"><span class="hs-identifier hs-var">mkVarApps</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; LevelledExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962462"><span class="hs-identifier hs-var">new_bndr</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962458"><span class="hs-identifier hs-var">lam_bndrs1</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-1234"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962453"><span class="hs-identifier hs-var">poly_env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1235"></span><span>
</span><span id="line-1236"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>  </span><span class="hs-comment">-- Non-null abs_vars</span><span>
</span><span id="line-1237"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680962451"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962451"><span class="hs-identifier hs-var">new_env</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962450"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962450"><span class="hs-identifier hs-var">new_bndrs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Level -&gt; LevelEnv -&gt; [Id] -&gt; [Id] -&gt; LvlM (LevelEnv, [Id])
</span><a href="GHC.Core.Opt.SetLevels.html#newPolyBndrs"><span class="hs-identifier hs-var">newPolyBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962485"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962488"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962474"><span class="hs-identifier hs-var">abs_vars</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962483"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-1238"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621680962449"><span class="annot"><span class="annottext">[LevelledExpr]
</span><a href="#local-6989586621680962449"><span class="hs-identifier hs-var">new_rhss</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">((Id, CoreExprWithFVs) -&gt; LvlM LevelledExpr)
-&gt; [(Id, CoreExprWithFVs)] -&gt; UniqSM [LevelledExpr]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; (Id, CoreExprWithFVs) -&gt; LvlM LevelledExpr
</span><a href="#local-6989586621680962470"><span class="hs-identifier hs-var">do_rhs</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962451"><span class="hs-identifier hs-var">new_env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExprWithFVs)]
</span><a href="#local-6989586621680962486"><span class="hs-identifier hs-var">pairs</span></a></span><span>
</span><span id="line-1239"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(LevelledBind, LevelEnv) -&gt; LvlM (LevelledBind, LevelEnv)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">[(LevelledBndr, LevelledExpr)] -&gt; LevelledBind
forall b. [(b, Expr b)] -&gt; Bind b
</span><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-var">Rec</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><span class="annottext">Id -&gt; FloatSpec -&gt; LevelledBndr
forall t. Id -&gt; t -&gt; TaggedBndr t
</span><a href="GHC.Core.html#TB"><span class="hs-identifier hs-var">TB</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962448"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Level -&gt; FloatSpec
</span><a href="GHC.Core.Opt.SetLevels.html#FloatMe"><span class="hs-identifier hs-var">FloatMe</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962485"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621680962448"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962448"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962450"><span class="hs-identifier hs-var">new_bndrs</span></a></span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">[LevelledBndr] -&gt; [LevelledExpr] -&gt; [(LevelledBndr, LevelledExpr)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-operator hs-var">`zip`</span></a></span><span> </span><span class="annot"><span class="annottext">[LevelledExpr]
</span><a href="#local-6989586621680962449"><span class="hs-identifier hs-var">new_rhss</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1240"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962451"><span class="hs-identifier hs-var">new_env</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1241"></span><span>
</span><span id="line-1242"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1243"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680962483"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962483"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680962447"><span class="annot"><span class="annottext">[CoreExprWithFVs]
</span><a href="#local-6989586621680962447"><span class="hs-identifier hs-var">rhss</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExprWithFVs)] -&gt; ([Id], [CoreExprWithFVs])
forall a b. [(a, b)] -&gt; ([a], [b])
</span><a href="../../base/src/GHC.List.html#unzip"><span class="hs-identifier hs-var">unzip</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExprWithFVs)]
</span><a href="#local-6989586621680962486"><span class="hs-identifier hs-var">pairs</span></a></span><span>
</span><span id="line-1244"></span><span>    </span><span id="local-6989586621680962445"><span class="annot"><span class="annottext">is_join :: Bool
</span><a href="#local-6989586621680962445"><span class="hs-identifier hs-var hs-var">is_join</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Id.html#isJoinId"><span class="hs-identifier hs-var">isJoinId</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id] -&gt; Id
forall a. [a] -&gt; a
</span><a href="../../base/src/GHC.List.html#head"><span class="hs-identifier hs-var">head</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962483"><span class="hs-identifier hs-var">bndrs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1245"></span><span>                </span><span class="hs-comment">-- bndrs is always non-empty and if one is a join they all are</span><span>
</span><span id="line-1246"></span><span>                </span><span class="hs-comment">-- Both are checked by Lint</span><span>
</span><span id="line-1247"></span><span>    </span><span id="local-6989586621680962442"><span class="annot"><span class="annottext">is_fun :: Bool
</span><a href="#local-6989586621680962442"><span class="hs-identifier hs-var hs-var">is_fun</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CoreExprWithFVs -&gt; Bool) -&gt; [CoreExprWithFVs] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#all"><span class="hs-identifier hs-var">all</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#isFunction"><span class="hs-identifier hs-var">isFunction</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExprWithFVs]
</span><a href="#local-6989586621680962447"><span class="hs-identifier hs-var">rhss</span></a></span><span>
</span><span id="line-1248"></span><span>    </span><span id="local-6989586621680962476"><span class="annot"><span class="annottext">is_bot :: Bool
</span><a href="#local-6989586621680962476"><span class="hs-identifier hs-var hs-var">is_bot</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>  </span><span class="hs-comment">-- It's odd to have an unconditionally divergent</span><span>
</span><span id="line-1249"></span><span>                      </span><span class="hs-comment">-- function in a Rec, and we don't much care what</span><span>
</span><span id="line-1250"></span><span>                      </span><span class="hs-comment">-- happens to it.  False is simple!</span><span>
</span><span id="line-1251"></span><span>
</span><span id="line-1252"></span><span>    </span><span id="local-6989586621680962470"><span class="annot"><span class="annottext">do_rhs :: LevelEnv -&gt; (Id, CoreExprWithFVs) -&gt; LvlM LevelledExpr
</span><a href="#local-6989586621680962470"><span class="hs-identifier hs-var hs-var">do_rhs</span></a></span></span><span> </span><span id="local-6989586621680962440"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962440"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680962439"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962439"><span class="hs-identifier hs-var">bndr</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680962438"><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962438"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id]
-&gt; Level
-&gt; LevelEnv
-&gt; RecFlag
-&gt; Bool
-&gt; Maybe Int
-&gt; CoreExprWithFVs
-&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlFloatRhs"><span class="hs-identifier hs-var">lvlFloatRhs</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962474"><span class="hs-identifier hs-var">abs_vars</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962485"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962440"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="GHC.Types.Basic.html#Recursive"><span class="hs-identifier hs-var">Recursive</span></a></span><span>
</span><span id="line-1253"></span><span>                                        </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962476"><span class="hs-identifier hs-var">is_bot</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Maybe Int
</span><a href="#local-6989586621680962454"><span class="hs-identifier hs-var">get_join</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962439"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1254"></span><span>                                        </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962438"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-1255"></span><span>
</span><span id="line-1256"></span><span>    </span><span id="local-6989586621680962454"><span class="annot"><span class="annottext">get_join :: Id -&gt; Maybe Int
</span><a href="#local-6989586621680962454"><span class="hs-identifier hs-var hs-var">get_join</span></a></span></span><span> </span><span id="local-6989586621680962437"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962437"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962436"><span class="hs-identifier hs-var">need_zap</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Int
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-1257"></span><span>                  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Maybe Int
</span><a href="GHC.Types.Id.html#isJoinId_maybe"><span class="hs-identifier hs-var">isJoinId_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962437"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-1258"></span><span>    </span><span id="local-6989586621680962436"><span class="annot"><span class="annottext">need_zap :: Bool
</span><a href="#local-6989586621680962436"><span class="hs-identifier hs-var hs-var">need_zap</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962485"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">Level -&gt; Level -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#ltLvl"><span class="hs-operator hs-var">`ltLvl`</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#joinCeilingLevel"><span class="hs-identifier hs-var">joinCeilingLevel</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962488"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-1259"></span><span>
</span><span id="line-1260"></span><span>        </span><span class="hs-comment">-- Finding the free vars of the binding group is annoying</span><span>
</span><span id="line-1261"></span><span>    </span><span id="local-6989586621680962434"><span class="annot"><span class="annottext">bind_fvs :: FVAnn
</span><a href="#local-6989586621680962434"><span class="hs-identifier hs-var hs-var">bind_fvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">[FVAnn] -&gt; FVAnn
</span><a href="GHC.Types.Var.Set.html#unionDVarSets"><span class="hs-identifier hs-var">unionDVarSets</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs -&gt; FVAnn
</span><a href="GHC.Core.FVs.html#freeVarsOf"><span class="hs-identifier hs-var">freeVarsOf</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962432"><span class="hs-identifier hs-var">rhs</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962432"><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962432"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExprWithFVs)]
</span><a href="#local-6989586621680962486"><span class="hs-identifier hs-var">pairs</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1262"></span><span>                </span><span class="annot"><span class="annottext">FVAnn -&gt; FVAnn -&gt; FVAnn
</span><a href="GHC.Types.Var.Set.html#unionDVarSet"><span class="hs-operator hs-var">`unionDVarSet`</span></a></span><span>
</span><span id="line-1263"></span><span>                </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FV -&gt; FVAnn
</span><a href="GHC.Utils.FV.html#fvDVarSet"><span class="hs-identifier hs-var">fvDVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">(FV -&gt; FVAnn) -&gt; FV -&gt; FVAnn
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[FV] -&gt; FV
</span><a href="GHC.Utils.FV.html#unionsFV"><span class="hs-identifier hs-var">unionsFV</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Id -&gt; FV
</span><a href="GHC.Core.FVs.html#idFVs"><span class="hs-identifier hs-var">idFVs</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962428"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-1264"></span><span>                                      </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680962428"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962428"><span class="hs-identifier hs-var">bndr</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FVAnn
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">AnnExpr' Id FVAnn
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExprWithFVs)]
</span><a href="#local-6989586621680962486"><span class="hs-identifier hs-var">pairs</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1265"></span><span>               </span><span class="annot"><span class="annottext">FVAnn -&gt; [Id] -&gt; FVAnn
</span><a href="GHC.Types.Var.Set.html#delDVarSetList"><span class="hs-operator hs-var">`delDVarSetList`</span></a></span><span>
</span><span id="line-1266"></span><span>                </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962483"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-1267"></span><span>
</span><span id="line-1268"></span><span>    </span><span id="local-6989586621680962425"><span class="annot"><span class="annottext">ty_fvs :: TyCoVarSet
</span><a href="#local-6989586621680962425"><span class="hs-identifier hs-var hs-var">ty_fvs</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; TyCoVarSet -&gt; TyCoVarSet)
-&gt; TyCoVarSet -&gt; [Id] -&gt; TyCoVarSet
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCoVarSet -&gt; TyCoVarSet -&gt; TyCoVarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-identifier hs-var">unionVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">(TyCoVarSet -&gt; TyCoVarSet -&gt; TyCoVarSet)
-&gt; (Id -&gt; TyCoVarSet) -&gt; Id -&gt; TyCoVarSet -&gt; TyCoVarSet
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; TyCoVarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfType"><span class="hs-identifier hs-var">tyCoVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">(Type -&gt; TyCoVarSet) -&gt; (Id -&gt; Type) -&gt; Id -&gt; TyCoVarSet
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TyCoVarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962483"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-1269"></span><span>    </span><span id="local-6989586621680962485"><span class="annot"><span class="annottext">dest_lvl :: Level
</span><a href="#local-6989586621680962485"><span class="hs-identifier hs-var hs-var">dest_lvl</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; FVAnn -&gt; TyCoVarSet -&gt; Bool -&gt; Bool -&gt; Bool -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#destLevel"><span class="hs-identifier hs-var">destLevel</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962488"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">FVAnn
</span><a href="#local-6989586621680962434"><span class="hs-identifier hs-var">bind_fvs</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVarSet
</span><a href="#local-6989586621680962425"><span class="hs-identifier hs-var">ty_fvs</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962442"><span class="hs-identifier hs-var">is_fun</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962476"><span class="hs-identifier hs-var">is_bot</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962445"><span class="hs-identifier hs-var">is_join</span></a></span><span>
</span><span id="line-1270"></span><span>    </span><span id="local-6989586621680962474"><span class="annot"><span class="annottext">abs_vars :: [Id]
</span><a href="#local-6989586621680962474"><span class="hs-identifier hs-var hs-var">abs_vars</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level -&gt; LevelEnv -&gt; FVAnn -&gt; [Id]
</span><a href="GHC.Core.Opt.SetLevels.html#abstractVars"><span class="hs-identifier hs-var">abstractVars</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962485"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962488"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">FVAnn
</span><a href="#local-6989586621680962434"><span class="hs-identifier hs-var">bind_fvs</span></a></span><span>
</span><span id="line-1271"></span><span>
</span><span id="line-1272"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#profitableFloat"><span class="hs-identifier hs-type">profitableFloat</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1273"></span><span id="profitableFloat"><span class="annot"><span class="annottext">profitableFloat :: LevelEnv -&gt; Level -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#profitableFloat"><span class="hs-identifier hs-var hs-var">profitableFloat</span></a></span></span><span> </span><span id="local-6989586621680962421"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962421"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680962420"><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962420"><span class="hs-identifier hs-var">dest_lvl</span></a></span></span><span>
</span><span id="line-1274"></span><span>  </span><span class="hs-glyph">=</span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962420"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">Level -&gt; Level -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#ltMajLvl"><span class="hs-operator hs-var">`ltMajLvl`</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#le_ctxt_lvl"><span class="hs-identifier hs-var hs-var">le_ctxt_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962421"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- Escapes a value lambda</span><span>
</span><span id="line-1275"></span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Level -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#isTopLvl"><span class="hs-identifier hs-var">isTopLvl</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962420"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span>                      </span><span class="hs-comment">-- Going all the way to top level</span><span>
</span><span id="line-1276"></span><span>
</span><span id="line-1277"></span><span>
</span><span id="line-1278"></span><span class="hs-comment">----------------------------------------------------</span><span>
</span><span id="line-1279"></span><span class="hs-comment">-- Three help functions for the type-abstraction case</span><span>
</span><span id="line-1280"></span><span>
</span><span id="line-1281"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#lvlRhs"><span class="hs-identifier hs-type">lvlRhs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span>
</span><span id="line-1282"></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#RecFlag"><span class="hs-identifier hs-type">RecFlag</span></a></span><span>
</span><span id="line-1283"></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>               </span><span class="hs-comment">-- Is this a bottoming function</span><span>
</span><span id="line-1284"></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#JoinArity"><span class="hs-identifier hs-type">JoinArity</span></a></span><span>
</span><span id="line-1285"></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.FVs.html#CoreExprWithFVs"><span class="hs-identifier hs-type">CoreExprWithFVs</span></a></span><span>
</span><span id="line-1286"></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LvlM"><span class="hs-identifier hs-type">LvlM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelledExpr"><span class="hs-identifier hs-type">LevelledExpr</span></a></span><span>
</span><span id="line-1287"></span><span id="lvlRhs"><span class="annot"><span class="annottext">lvlRhs :: LevelEnv
-&gt; RecFlag
-&gt; Bool
-&gt; Maybe Int
-&gt; CoreExprWithFVs
-&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlRhs"><span class="hs-identifier hs-var hs-var">lvlRhs</span></a></span></span><span> </span><span id="local-6989586621680962418"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962418"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680962417"><span class="annot"><span class="annottext">RecFlag
</span><a href="#local-6989586621680962417"><span class="hs-identifier hs-var">rec_flag</span></a></span></span><span> </span><span id="local-6989586621680962416"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962416"><span class="hs-identifier hs-var">is_bot</span></a></span></span><span> </span><span id="local-6989586621680962415"><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621680962415"><span class="hs-identifier hs-var">mb_join_arity</span></a></span></span><span> </span><span id="local-6989586621680962414"><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962414"><span class="hs-identifier hs-var">expr</span></a></span></span><span>
</span><span id="line-1288"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id]
-&gt; Level
-&gt; LevelEnv
-&gt; RecFlag
-&gt; Bool
-&gt; Maybe Int
-&gt; CoreExprWithFVs
-&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlFloatRhs"><span class="hs-identifier hs-var">lvlFloatRhs</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#le_ctxt_lvl"><span class="hs-identifier hs-var hs-var">le_ctxt_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962418"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962418"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-1289"></span><span>                </span><span class="annot"><span class="annottext">RecFlag
</span><a href="#local-6989586621680962417"><span class="hs-identifier hs-var">rec_flag</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962416"><span class="hs-identifier hs-var">is_bot</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621680962415"><span class="hs-identifier hs-var">mb_join_arity</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962414"><span class="hs-identifier hs-var">expr</span></a></span><span>
</span><span id="line-1290"></span><span>
</span><span id="line-1291"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#lvlFloatRhs"><span class="hs-identifier hs-type">lvlFloatRhs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#OutVar"><span class="hs-identifier hs-type">OutVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#RecFlag"><span class="hs-identifier hs-type">RecFlag</span></a></span><span>
</span><span id="line-1292"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>   </span><span class="hs-comment">-- Binding is for a bottoming function</span><span>
</span><span id="line-1293"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#JoinArity"><span class="hs-identifier hs-type">JoinArity</span></a></span><span>
</span><span id="line-1294"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.FVs.html#CoreExprWithFVs"><span class="hs-identifier hs-type">CoreExprWithFVs</span></a></span><span>
</span><span id="line-1295"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LvlM"><span class="hs-identifier hs-type">LvlM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Expr"><span class="hs-identifier hs-type">Expr</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelledBndr"><span class="hs-identifier hs-type">LevelledBndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1296"></span><span class="hs-comment">-- Ignores the le_ctxt_lvl in env; treats dest_lvl as the baseline</span><span>
</span><span id="line-1297"></span><span id="lvlFloatRhs"><span class="annot"><span class="annottext">lvlFloatRhs :: [Id]
-&gt; Level
-&gt; LevelEnv
-&gt; RecFlag
-&gt; Bool
-&gt; Maybe Int
-&gt; CoreExprWithFVs
-&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlFloatRhs"><span class="hs-identifier hs-var hs-var">lvlFloatRhs</span></a></span></span><span> </span><span id="local-6989586621680962412"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962412"><span class="hs-identifier hs-var">abs_vars</span></a></span></span><span> </span><span id="local-6989586621680962411"><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962411"><span class="hs-identifier hs-var">dest_lvl</span></a></span></span><span> </span><span id="local-6989586621680962410"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962410"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680962409"><span class="annot"><span class="annottext">RecFlag
</span><a href="#local-6989586621680962409"><span class="hs-identifier hs-var">rec</span></a></span></span><span> </span><span id="local-6989586621680962408"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962408"><span class="hs-identifier hs-var">is_bot</span></a></span></span><span> </span><span id="local-6989586621680962407"><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621680962407"><span class="hs-identifier hs-var">mb_join_arity</span></a></span></span><span> </span><span id="local-6989586621680962406"><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962406"><span class="hs-identifier hs-var">rhs</span></a></span></span><span>
</span><span id="line-1298"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680962405"><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962405"><span class="hs-identifier hs-var">body'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962408"><span class="hs-identifier hs-var">is_bot</span></a></span><span>  </span><span class="hs-comment">-- See Note [Floating from a RHS]</span><span>
</span><span id="line-1299"></span><span>                     </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Bool) -&gt; [Id] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#any"><span class="hs-identifier hs-var">any</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isId"><span class="hs-identifier hs-var">isId</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962404"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-1300"></span><span>                  </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Bool -&gt; CoreExprWithFVs -&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlMFE"><span class="hs-identifier hs-var">lvlMFE</span></a></span><span>  </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962403"><span class="hs-identifier hs-var">body_env</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962402"><span class="hs-identifier hs-var">body</span></a></span><span>
</span><span id="line-1301"></span><span>                  </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; CoreExprWithFVs -&gt; LvlM LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lvlExpr"><span class="hs-identifier hs-var">lvlExpr</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962403"><span class="hs-identifier hs-var">body_env</span></a></span><span>      </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962402"><span class="hs-identifier hs-var">body</span></a></span><span>
</span><span id="line-1302"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">LevelledExpr -&gt; LvlM LevelledExpr
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[LevelledBndr] -&gt; LevelledExpr -&gt; LevelledExpr
forall b. [b] -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#mkLams"><span class="hs-identifier hs-var">mkLams</span></a></span><span> </span><span class="annot"><span class="annottext">[LevelledBndr]
</span><a href="#local-6989586621680962401"><span class="hs-identifier hs-var">bndrs'</span></a></span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962405"><span class="hs-identifier hs-var">body'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1303"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1304"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680962404"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962404"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962402"><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962402"><span class="hs-identifier hs-var">body</span></a></span></span><span class="hs-special">)</span><span>     </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680962400"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962400"><span class="hs-identifier hs-var">join_arity</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621680962407"><span class="hs-identifier hs-var">mb_join_arity</span></a></span><span>
</span><span id="line-1305"></span><span>                      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; CoreExprWithFVs -&gt; ([Id], CoreExprWithFVs)
forall bndr annot.
Int -&gt; AnnExpr bndr annot -&gt; ([bndr], AnnExpr bndr annot)
</span><a href="GHC.Core.html#collectNAnnBndrs"><span class="hs-identifier hs-var">collectNAnnBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962400"><span class="hs-identifier hs-var">join_arity</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962406"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-1306"></span><span>                      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1307"></span><span>                      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs -&gt; ([Id], CoreExprWithFVs)
forall bndr annot.
AnnExpr bndr annot -&gt; ([bndr], AnnExpr bndr annot)
</span><a href="GHC.Core.html#collectAnnBndrs"><span class="hs-identifier hs-var">collectAnnBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962406"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-1308"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680962398"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962398"><span class="hs-identifier hs-var">env1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962397"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962397"><span class="hs-identifier hs-var">bndrs1</span></a></span></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RecFlag -&gt; LevelEnv -&gt; [Id] -&gt; (LevelEnv, [Id])
</span><a href="GHC.Core.Opt.SetLevels.html#substBndrsSL"><span class="hs-identifier hs-var">substBndrsSL</span></a></span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="GHC.Types.Basic.html#NonRecursive"><span class="hs-identifier hs-var">NonRecursive</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962410"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962404"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-1309"></span><span>    </span><span id="local-6989586621680962396"><span class="annot"><span class="annottext">all_bndrs :: [Id]
</span><a href="#local-6989586621680962396"><span class="hs-identifier hs-var hs-var">all_bndrs</span></a></span></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962412"><span class="hs-identifier hs-var">abs_vars</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [Id] -&gt; [Id]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962397"><span class="hs-identifier hs-var">bndrs1</span></a></span><span>
</span><span id="line-1310"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680962403"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962403"><span class="hs-identifier hs-var">body_env</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962401"><span class="annot"><span class="annottext">[LevelledBndr]
</span><a href="#local-6989586621680962401"><span class="hs-identifier hs-var">bndrs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621680962407"><span class="hs-identifier hs-var">mb_join_arity</span></a></span><span>
</span><span id="line-1311"></span><span>                      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Level -&gt; RecFlag -&gt; [Id] -&gt; (LevelEnv, [LevelledBndr])
</span><a href="GHC.Core.Opt.SetLevels.html#lvlJoinBndrs"><span class="hs-identifier hs-var">lvlJoinBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962398"><span class="hs-identifier hs-var">env1</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962411"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="#local-6989586621680962409"><span class="hs-identifier hs-var">rec</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962396"><span class="hs-identifier hs-var">all_bndrs</span></a></span><span>
</span><span id="line-1312"></span><span>                      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1313"></span><span>                      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Level -&gt; [Id] -&gt; (LevelEnv, [LevelledBndr])
</span><a href="GHC.Core.Opt.SetLevels.html#lvlLamBndrs"><span class="hs-identifier hs-var">lvlLamBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962398"><span class="hs-identifier hs-var">env1</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962411"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962396"><span class="hs-identifier hs-var">all_bndrs</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1314"></span><span>                          </span><span class="hs-special">(</span><span id="local-6989586621680962394"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962394"><span class="hs-identifier hs-var">env2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962393"><span class="annot"><span class="annottext">[LevelledBndr]
</span><a href="#local-6989586621680962393"><span class="hs-identifier hs-var">bndrs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; LevelEnv
</span><a href="GHC.Core.Opt.SetLevels.html#placeJoinCeiling"><span class="hs-identifier hs-var">placeJoinCeiling</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962394"><span class="hs-identifier hs-var">env2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[LevelledBndr]
</span><a href="#local-6989586621680962393"><span class="hs-identifier hs-var">bndrs'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1315"></span><span>        </span><span class="hs-comment">-- The important thing here is that we call lvlLamBndrs on</span><span>
</span><span id="line-1316"></span><span>        </span><span class="hs-comment">-- all these binders at once (abs_vars and bndrs), so they</span><span>
</span><span id="line-1317"></span><span>        </span><span class="hs-comment">-- all get the same major level.  Otherwise we create stupid</span><span>
</span><span id="line-1318"></span><span>        </span><span class="hs-comment">-- let-bindings inside, joyfully thinking they can float; but</span><span>
</span><span id="line-1319"></span><span>        </span><span class="hs-comment">-- in the end they don't because we never float bindings in</span><span>
</span><span id="line-1320"></span><span>        </span><span class="hs-comment">-- between lambdas</span><span>
</span><span id="line-1321"></span><span>
</span><span id="line-1322"></span><span class="hs-comment">{- Note [Floating from a RHS]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When floating the RHS of a let-binding, we don't always want to apply
lvlMFE to the body of a lambda, as we usually do, because the entire
binding body is already going to the right place (dest_lvl).

A particular example is the top level.  Consider
   concat = /\ a -&gt; foldr ..a.. (++) []
We don't want to float the body of the lambda to get
   lvl    = /\ a -&gt; foldr ..a.. (++) []
   concat = /\ a -&gt; lvl a
That would be stupid.

Previously this was avoided in a much nastier way, by testing strict_ctxt
in float_me in lvlMFE.  But that wasn't even right because it would fail
to float out the error sub-expression in
    f = \x. case x of
              True  -&gt; error (&quot;blah&quot; ++ show x)
              False -&gt; ...

But we must be careful:

* If we had
    f = \x -&gt; factorial 20
  we /would/ want to float that (factorial 20) out!  Functions are treated
  differently: see the use of isFunction in the calls to destLevel. If
  there are only type lambdas, then destLevel will say &quot;go to top, and
  abstract over the free tyvars&quot; and we don't want that here.

* But if we had
    f = \x -&gt; error (...x....)
  we would NOT want to float the bottoming expression out to give
    lvl = \x -&gt; error (...x...)
    f = \x -&gt; lvl x

Conclusion: use lvlMFE if there are
  * any value lambdas in the original function, and
  * this is not a bottoming function (the is_bot argument)
Use lvlExpr otherwise.  A little subtle, and I got it wrong at least twice
(e.g. #13369).
-}</span><span>
</span><span id="line-1363"></span><span>
</span><span id="line-1364"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
\subsection{Deciding floatability}
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-1371"></span><span>
</span><span id="line-1372"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#substAndLvlBndrs"><span class="hs-identifier hs-type">substAndLvlBndrs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#RecFlag"><span class="hs-identifier hs-type">RecFlag</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#InVar"><span class="hs-identifier hs-type">InVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelledBndr"><span class="hs-identifier hs-type">LevelledBndr</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1373"></span><span id="substAndLvlBndrs"><span class="annot"><span class="annottext">substAndLvlBndrs :: RecFlag -&gt; LevelEnv -&gt; Level -&gt; [Id] -&gt; (LevelEnv, [LevelledBndr])
</span><a href="GHC.Core.Opt.SetLevels.html#substAndLvlBndrs"><span class="hs-identifier hs-var hs-var">substAndLvlBndrs</span></a></span></span><span> </span><span id="local-6989586621680962391"><span class="annot"><span class="annottext">RecFlag
</span><a href="#local-6989586621680962391"><span class="hs-identifier hs-var">is_rec</span></a></span></span><span> </span><span id="local-6989586621680962390"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962390"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680962389"><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962389"><span class="hs-identifier hs-var">lvl</span></a></span></span><span> </span><span id="local-6989586621680962388"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962388"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span>
</span><span id="line-1374"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Level -&gt; [Id] -&gt; (LevelEnv, [LevelledBndr])
</span><a href="GHC.Core.Opt.SetLevels.html#lvlBndrs"><span class="hs-identifier hs-var">lvlBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962386"><span class="hs-identifier hs-var">subst_env</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962389"><span class="hs-identifier hs-var">lvl</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962385"><span class="hs-identifier hs-var">subst_bndrs</span></a></span><span>
</span><span id="line-1375"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1376"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680962386"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962386"><span class="hs-identifier hs-var">subst_env</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962385"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962385"><span class="hs-identifier hs-var">subst_bndrs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RecFlag -&gt; LevelEnv -&gt; [Id] -&gt; (LevelEnv, [Id])
</span><a href="GHC.Core.Opt.SetLevels.html#substBndrsSL"><span class="hs-identifier hs-var">substBndrsSL</span></a></span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="#local-6989586621680962391"><span class="hs-identifier hs-var">is_rec</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962390"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962388"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-1377"></span><span>
</span><span id="line-1378"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#substBndrsSL"><span class="hs-identifier hs-type">substBndrsSL</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#RecFlag"><span class="hs-identifier hs-type">RecFlag</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#InVar"><span class="hs-identifier hs-type">InVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#OutVar"><span class="hs-identifier hs-type">OutVar</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1379"></span><span class="hs-comment">-- So named only to avoid the name clash with GHC.Core.Subst.substBndrs</span><span>
</span><span id="line-1380"></span><span id="substBndrsSL"><span class="annot"><span class="annottext">substBndrsSL :: RecFlag -&gt; LevelEnv -&gt; [Id] -&gt; (LevelEnv, [Id])
</span><a href="GHC.Core.Opt.SetLevels.html#substBndrsSL"><span class="hs-identifier hs-var hs-var">substBndrsSL</span></a></span></span><span> </span><span id="local-6989586621680962384"><span class="annot"><span class="annottext">RecFlag
</span><a href="#local-6989586621680962384"><span class="hs-identifier hs-var">is_rec</span></a></span></span><span> </span><span id="local-6989586621680962383"><span class="annot"><span class="annottext">env :: LevelEnv
</span><a href="#local-6989586621680962383"><span class="hs-identifier hs-var">env</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LE"><span class="hs-identifier hs-type">LE</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">le_subst :: LevelEnv -&gt; Subst
</span><a href="GHC.Core.Opt.SetLevels.html#le_subst"><span class="hs-identifier hs-var">le_subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680962381"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680962381"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">le_env :: LevelEnv -&gt; IdEnv ([Id], LevelledExpr)
</span><a href="GHC.Core.Opt.SetLevels.html#le_env"><span class="hs-identifier hs-var">le_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680962379"><span class="annot"><span class="annottext">IdEnv ([Id], LevelledExpr)
</span><a href="#local-6989586621680962379"><span class="hs-identifier hs-var">id_env</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621680962378"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962378"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span>
</span><span id="line-1381"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962383"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">le_subst :: Subst
</span><a href="GHC.Core.Opt.SetLevels.html#le_subst"><span class="hs-identifier hs-var">le_subst</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680962377"><span class="hs-identifier hs-var">subst'</span></a></span><span>
</span><span id="line-1382"></span><span>          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">le_env :: IdEnv ([Id], LevelledExpr)
</span><a href="GHC.Core.Opt.SetLevels.html#le_env"><span class="hs-identifier hs-var">le_env</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(IdEnv ([Id], LevelledExpr)
 -&gt; (Id, Id) -&gt; IdEnv ([Id], LevelledExpr))
-&gt; IdEnv ([Id], LevelledExpr)
-&gt; [(Id, Id)]
-&gt; IdEnv ([Id], LevelledExpr)
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">IdEnv ([Id], LevelledExpr)
-&gt; (Id, Id) -&gt; IdEnv ([Id], LevelledExpr)
</span><a href="GHC.Core.Opt.SetLevels.html#add_id"><span class="hs-identifier hs-var">add_id</span></a></span><span>  </span><span class="annot"><span class="annottext">IdEnv ([Id], LevelledExpr)
</span><a href="#local-6989586621680962379"><span class="hs-identifier hs-var">id_env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962378"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [Id] -&gt; [(Id, Id)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-operator hs-var">`zip`</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962375"><span class="hs-identifier hs-var">bndrs'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1383"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962375"><span class="hs-identifier hs-var">bndrs'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1384"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1385"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680962377"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680962377"><span class="hs-identifier hs-var">subst'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962375"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962375"><span class="hs-identifier hs-var">bndrs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="#local-6989586621680962384"><span class="hs-identifier hs-var">is_rec</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1386"></span><span>                         </span><span class="annot"><span class="annottext">RecFlag
</span><a href="GHC.Types.Basic.html#NonRecursive"><span class="hs-identifier hs-var">NonRecursive</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; [Id] -&gt; (Subst, [Id])
</span><a href="GHC.Core.Subst.html#substBndrs"><span class="hs-identifier hs-var">substBndrs</span></a></span><span>    </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680962381"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962378"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-1387"></span><span>                         </span><span class="annot"><span class="annottext">RecFlag
</span><a href="GHC.Types.Basic.html#Recursive"><span class="hs-identifier hs-var">Recursive</span></a></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; [Id] -&gt; (Subst, [Id])
</span><a href="GHC.Core.Subst.html#substRecBndrs"><span class="hs-identifier hs-var">substRecBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680962381"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962378"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-1388"></span><span>
</span><span id="line-1389"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#lvlLamBndrs"><span class="hs-identifier hs-type">lvlLamBndrs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#OutVar"><span class="hs-identifier hs-type">OutVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelledBndr"><span class="hs-identifier hs-type">LevelledBndr</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1390"></span><span class="hs-comment">-- Compute the levels for the binders of a lambda group</span><span>
</span><span id="line-1391"></span><span id="lvlLamBndrs"><span class="annot"><span class="annottext">lvlLamBndrs :: LevelEnv -&gt; Level -&gt; [Id] -&gt; (LevelEnv, [LevelledBndr])
</span><a href="GHC.Core.Opt.SetLevels.html#lvlLamBndrs"><span class="hs-identifier hs-var hs-var">lvlLamBndrs</span></a></span></span><span> </span><span id="local-6989586621680962372"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962372"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680962371"><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962371"><span class="hs-identifier hs-var">lvl</span></a></span></span><span> </span><span id="local-6989586621680962370"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962370"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span>
</span><span id="line-1392"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Level -&gt; [Id] -&gt; (LevelEnv, [LevelledBndr])
</span><a href="GHC.Core.Opt.SetLevels.html#lvlBndrs"><span class="hs-identifier hs-var">lvlBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962372"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962369"><span class="hs-identifier hs-var">new_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962370"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-1393"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1394"></span><span>    </span><span id="local-6989586621680962369"><span class="annot"><span class="annottext">new_lvl :: Level
</span><a href="#local-6989586621680962369"><span class="hs-identifier hs-var hs-var">new_lvl</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Bool) -&gt; [Id] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#any"><span class="hs-identifier hs-var">any</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="#local-6989586621680962367"><span class="hs-identifier hs-var">is_major</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962370"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#incMajorLvl"><span class="hs-identifier hs-var">incMajorLvl</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962371"><span class="hs-identifier hs-var">lvl</span></a></span><span>
</span><span id="line-1395"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#incMinorLvl"><span class="hs-identifier hs-var">incMinorLvl</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962371"><span class="hs-identifier hs-var">lvl</span></a></span><span>
</span><span id="line-1396"></span><span>
</span><span id="line-1397"></span><span>    </span><span id="local-6989586621680962367"><span class="annot"><span class="annottext">is_major :: Id -&gt; Bool
</span><a href="#local-6989586621680962367"><span class="hs-identifier hs-var hs-var">is_major</span></a></span></span><span> </span><span id="local-6989586621680962366"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962366"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isId"><span class="hs-identifier hs-var">isId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962366"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Id.html#isProbablyOneShotLambda"><span class="hs-identifier hs-var">isProbablyOneShotLambda</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962366"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1398"></span><span>       </span><span class="hs-comment">-- The &quot;probably&quot; part says &quot;don't float things out of a</span><span>
</span><span id="line-1399"></span><span>       </span><span class="hs-comment">-- probable one-shot lambda&quot;</span><span>
</span><span id="line-1400"></span><span>       </span><span class="hs-comment">-- See Note [Computing one-shot info] in GHC.Types.Demand</span><span>
</span><span id="line-1401"></span><span>
</span><span id="line-1402"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#lvlJoinBndrs"><span class="hs-identifier hs-type">lvlJoinBndrs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#RecFlag"><span class="hs-identifier hs-type">RecFlag</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#OutVar"><span class="hs-identifier hs-type">OutVar</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1403"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelledBndr"><span class="hs-identifier hs-type">LevelledBndr</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1404"></span><span id="lvlJoinBndrs"><span class="annot"><span class="annottext">lvlJoinBndrs :: LevelEnv -&gt; Level -&gt; RecFlag -&gt; [Id] -&gt; (LevelEnv, [LevelledBndr])
</span><a href="GHC.Core.Opt.SetLevels.html#lvlJoinBndrs"><span class="hs-identifier hs-var hs-var">lvlJoinBndrs</span></a></span></span><span> </span><span id="local-6989586621680962364"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962364"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680962363"><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962363"><span class="hs-identifier hs-var">lvl</span></a></span></span><span> </span><span id="local-6989586621680962362"><span class="annot"><span class="annottext">RecFlag
</span><a href="#local-6989586621680962362"><span class="hs-identifier hs-var">rec</span></a></span></span><span> </span><span id="local-6989586621680962361"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962361"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span>
</span><span id="line-1405"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Level -&gt; [Id] -&gt; (LevelEnv, [LevelledBndr])
</span><a href="GHC.Core.Opt.SetLevels.html#lvlBndrs"><span class="hs-identifier hs-var">lvlBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962364"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962360"><span class="hs-identifier hs-var">new_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962361"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-1406"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1407"></span><span>    </span><span id="local-6989586621680962360"><span class="annot"><span class="annottext">new_lvl :: Level
</span><a href="#local-6989586621680962360"><span class="hs-identifier hs-var hs-var">new_lvl</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">RecFlag -&gt; Bool
</span><a href="GHC.Types.Basic.html#isRec"><span class="hs-identifier hs-var">isRec</span></a></span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="#local-6989586621680962362"><span class="hs-identifier hs-var">rec</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#incMajorLvl"><span class="hs-identifier hs-var">incMajorLvl</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962363"><span class="hs-identifier hs-var">lvl</span></a></span><span>
</span><span id="line-1408"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#incMinorLvl"><span class="hs-identifier hs-var">incMinorLvl</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962363"><span class="hs-identifier hs-var">lvl</span></a></span><span>
</span><span id="line-1409"></span><span>      </span><span class="hs-comment">-- Non-recursive join points are one-shot; recursive ones are not</span><span>
</span><span id="line-1410"></span><span>
</span><span id="line-1411"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#lvlBndrs"><span class="hs-identifier hs-type">lvlBndrs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBndr"><span class="hs-identifier hs-type">CoreBndr</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelledBndr"><span class="hs-identifier hs-type">LevelledBndr</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1412"></span><span class="hs-comment">-- The binders returned are exactly the same as the ones passed,</span><span>
</span><span id="line-1413"></span><span class="hs-comment">-- apart from applying the substitution, but they are now paired</span><span>
</span><span id="line-1414"></span><span class="hs-comment">-- with a (StayPut level)</span><span>
</span><span id="line-1415"></span><span class="hs-comment">--</span><span>
</span><span id="line-1416"></span><span class="hs-comment">-- The returned envt has le_ctxt_lvl updated to the new_lvl</span><span>
</span><span id="line-1417"></span><span class="hs-comment">--</span><span>
</span><span id="line-1418"></span><span class="hs-comment">-- All the new binders get the same level, because</span><span>
</span><span id="line-1419"></span><span class="hs-comment">-- any floating binding is either going to float past</span><span>
</span><span id="line-1420"></span><span class="hs-comment">-- all or none.  We never separate binders.</span><span>
</span><span id="line-1421"></span><span id="lvlBndrs"><span class="annot"><span class="annottext">lvlBndrs :: LevelEnv -&gt; Level -&gt; [Id] -&gt; (LevelEnv, [LevelledBndr])
</span><a href="GHC.Core.Opt.SetLevels.html#lvlBndrs"><span class="hs-identifier hs-var hs-var">lvlBndrs</span></a></span></span><span> </span><span id="local-6989586621680962358"><span class="annot"><span class="annottext">env :: LevelEnv
</span><a href="#local-6989586621680962358"><span class="hs-identifier hs-var">env</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LE"><span class="hs-identifier hs-type">LE</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">le_lvl_env :: LevelEnv -&gt; VarEnv Level
</span><a href="GHC.Core.Opt.SetLevels.html#le_lvl_env"><span class="hs-identifier hs-var">le_lvl_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680962356"><span class="annot"><span class="annottext">VarEnv Level
</span><a href="#local-6989586621680962356"><span class="hs-identifier hs-var">lvl_env</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621680962355"><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962355"><span class="hs-identifier hs-var">new_lvl</span></a></span></span><span> </span><span id="local-6989586621680962354"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962354"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span>
</span><span id="line-1422"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962358"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">le_ctxt_lvl :: Level
</span><a href="GHC.Core.Opt.SetLevels.html#le_ctxt_lvl"><span class="hs-identifier hs-var">le_ctxt_lvl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962355"><span class="hs-identifier hs-var">new_lvl</span></a></span><span>
</span><span id="line-1423"></span><span>          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">le_join_ceil :: Level
</span><a href="GHC.Core.Opt.SetLevels.html#le_join_ceil"><span class="hs-identifier hs-var">le_join_ceil</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962355"><span class="hs-identifier hs-var">new_lvl</span></a></span><span>
</span><span id="line-1424"></span><span>          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">le_lvl_env :: VarEnv Level
</span><a href="GHC.Core.Opt.SetLevels.html#le_lvl_env"><span class="hs-identifier hs-var">le_lvl_env</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level -&gt; VarEnv Level -&gt; [Id] -&gt; VarEnv Level
</span><a href="GHC.Core.Opt.SetLevels.html#addLvls"><span class="hs-identifier hs-var">addLvls</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962355"><span class="hs-identifier hs-var">new_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">VarEnv Level
</span><a href="#local-6989586621680962356"><span class="hs-identifier hs-var">lvl_env</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962354"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1425"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; LevelledBndr) -&gt; [Id] -&gt; [LevelledBndr]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Level -&gt; Id -&gt; LevelledBndr
</span><a href="GHC.Core.Opt.SetLevels.html#stayPut"><span class="hs-identifier hs-var">stayPut</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962355"><span class="hs-identifier hs-var">new_lvl</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962354"><span class="hs-identifier hs-var">bndrs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1426"></span><span>
</span><span id="line-1427"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#stayPut"><span class="hs-identifier hs-type">stayPut</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#OutVar"><span class="hs-identifier hs-type">OutVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelledBndr"><span class="hs-identifier hs-type">LevelledBndr</span></a></span><span>
</span><span id="line-1428"></span><span id="stayPut"><span class="annot"><span class="annottext">stayPut :: Level -&gt; Id -&gt; LevelledBndr
</span><a href="GHC.Core.Opt.SetLevels.html#stayPut"><span class="hs-identifier hs-var hs-var">stayPut</span></a></span></span><span> </span><span id="local-6989586621680962351"><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962351"><span class="hs-identifier hs-var">new_lvl</span></a></span></span><span> </span><span id="local-6989586621680962350"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962350"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; FloatSpec -&gt; LevelledBndr
forall t. Id -&gt; t -&gt; TaggedBndr t
</span><a href="GHC.Core.html#TB"><span class="hs-identifier hs-var">TB</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962350"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Level -&gt; FloatSpec
</span><a href="GHC.Core.Opt.SetLevels.html#StayPut"><span class="hs-identifier hs-var">StayPut</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962351"><span class="hs-identifier hs-var">new_lvl</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1429"></span><span>
</span><span id="line-1430"></span><span>  </span><span class="hs-comment">-- Destination level is the max Id level of the expression</span><span>
</span><span id="line-1431"></span><span>  </span><span class="hs-comment">-- (We'll abstract the type variables, if any.)</span><span>
</span><span id="line-1432"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#destLevel"><span class="hs-identifier hs-type">destLevel</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span>
</span><span id="line-1433"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#DVarSet"><span class="hs-identifier hs-type">DVarSet</span></a></span><span>    </span><span class="hs-comment">-- Free vars of the term</span><span>
</span><span id="line-1434"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#TyCoVarSet"><span class="hs-identifier hs-type">TyCoVarSet</span></a></span><span> </span><span class="hs-comment">-- Free in the /type/ of the term</span><span>
</span><span id="line-1435"></span><span>                        </span><span class="hs-comment">-- (a subset of the previous argument)</span><span>
</span><span id="line-1436"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>   </span><span class="hs-comment">-- True &lt;=&gt; is function</span><span>
</span><span id="line-1437"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>   </span><span class="hs-comment">-- True &lt;=&gt; is bottom</span><span>
</span><span id="line-1438"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>   </span><span class="hs-comment">-- True &lt;=&gt; is a join point</span><span>
</span><span id="line-1439"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span>
</span><span id="line-1440"></span><span class="hs-comment">-- INVARIANT: if is_join=True then result &gt;= join_ceiling</span><span>
</span><span id="line-1441"></span><span id="destLevel"><span class="annot"><span class="annottext">destLevel :: LevelEnv -&gt; FVAnn -&gt; TyCoVarSet -&gt; Bool -&gt; Bool -&gt; Bool -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#destLevel"><span class="hs-identifier hs-var hs-var">destLevel</span></a></span></span><span> </span><span id="local-6989586621680962349"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962349"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680962348"><span class="annot"><span class="annottext">FVAnn
</span><a href="#local-6989586621680962348"><span class="hs-identifier hs-var">fvs</span></a></span></span><span> </span><span id="local-6989586621680962347"><span class="annot"><span class="annottext">TyCoVarSet
</span><a href="#local-6989586621680962347"><span class="hs-identifier hs-var">fvs_ty</span></a></span></span><span> </span><span id="local-6989586621680962346"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962346"><span class="hs-identifier hs-var">is_function</span></a></span></span><span> </span><span id="local-6989586621680962345"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962345"><span class="hs-identifier hs-var">is_bot</span></a></span></span><span> </span><span id="local-6989586621680962344"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962344"><span class="hs-identifier hs-var">is_join</span></a></span></span><span>
</span><span id="line-1442"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Level -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#isTopLvl"><span class="hs-identifier hs-var">isTopLvl</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962343"><span class="hs-identifier hs-var">max_fv_id_level</span></a></span><span>  </span><span class="hs-comment">-- Float even joins if they get to top level</span><span>
</span><span id="line-1443"></span><span>                              </span><span class="hs-comment">-- See Note [Floating join point bindings]</span><span>
</span><span id="line-1444"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="GHC.Core.Opt.SetLevels.html#tOP_LEVEL"><span class="hs-identifier hs-var">tOP_LEVEL</span></a></span><span>
</span><span id="line-1445"></span><span>
</span><span id="line-1446"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962344"><span class="hs-identifier hs-var">is_join</span></a></span><span>  </span><span class="hs-comment">-- Never float a join point past the join ceiling</span><span>
</span><span id="line-1447"></span><span>             </span><span class="hs-comment">-- See Note [Join points] in GHC.Core.Opt.FloatOut</span><span>
</span><span id="line-1448"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962343"><span class="hs-identifier hs-var">max_fv_id_level</span></a></span><span> </span><span class="annot"><span class="annottext">Level -&gt; Level -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#ltLvl"><span class="hs-operator hs-var">`ltLvl`</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962342"><span class="hs-identifier hs-var">join_ceiling</span></a></span><span>
</span><span id="line-1449"></span><span>    </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962342"><span class="hs-identifier hs-var">join_ceiling</span></a></span><span>
</span><span id="line-1450"></span><span>    </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962343"><span class="hs-identifier hs-var">max_fv_id_level</span></a></span><span>
</span><span id="line-1451"></span><span>
</span><span id="line-1452"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962345"><span class="hs-identifier hs-var">is_bot</span></a></span><span>              </span><span class="hs-comment">-- Send bottoming bindings to the top</span><span>
</span><span id="line-1453"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962341"><span class="hs-identifier hs-var">as_far_as_poss</span></a></span><span>      </span><span class="hs-comment">-- regardless; see Note [Bottoming floats]</span><span>
</span><span id="line-1454"></span><span>                        </span><span class="hs-comment">-- Esp Bottoming floats (1)</span><span>
</span><span id="line-1455"></span><span>
</span><span id="line-1456"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680962340"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962340"><span class="hs-identifier hs-var">n_args</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Maybe Int
</span><a href="GHC.Core.Opt.SetLevels.html#floatLams"><span class="hs-identifier hs-var">floatLams</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962349"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-1457"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962340"><span class="hs-identifier hs-var">n_args</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>  </span><span class="hs-comment">-- n=0 case handled uniformly by the 'otherwise' case</span><span>
</span><span id="line-1458"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962346"><span class="hs-identifier hs-var">is_function</span></a></span><span>
</span><span id="line-1459"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">FVAnn -&gt; Int
</span><a href="GHC.Core.Opt.SetLevels.html#countFreeIds"><span class="hs-identifier hs-var">countFreeIds</span></a></span><span> </span><span class="annot"><span class="annottext">FVAnn
</span><a href="#local-6989586621680962348"><span class="hs-identifier hs-var">fvs</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;=</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962340"><span class="hs-identifier hs-var">n_args</span></a></span><span>
</span><span id="line-1460"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962341"><span class="hs-identifier hs-var">as_far_as_poss</span></a></span><span>  </span><span class="hs-comment">-- Send functions to top level; see</span><span>
</span><span id="line-1461"></span><span>                    </span><span class="hs-comment">-- the comments with isFunction</span><span>
</span><span id="line-1462"></span><span>
</span><span id="line-1463"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962343"><span class="hs-identifier hs-var">max_fv_id_level</span></a></span><span>
</span><span id="line-1464"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1465"></span><span>    </span><span id="local-6989586621680962342"><span class="annot"><span class="annottext">join_ceiling :: Level
</span><a href="#local-6989586621680962342"><span class="hs-identifier hs-var hs-var">join_ceiling</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#joinCeilingLevel"><span class="hs-identifier hs-var">joinCeilingLevel</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962349"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-1466"></span><span>    </span><span id="local-6989586621680962343"><span class="annot"><span class="annottext">max_fv_id_level :: Level
</span><a href="#local-6989586621680962343"><span class="hs-identifier hs-var hs-var">max_fv_id_level</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Bool) -&gt; LevelEnv -&gt; FVAnn -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#maxFvLevel"><span class="hs-identifier hs-var">maxFvLevel</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isId"><span class="hs-identifier hs-var">isId</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962349"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">FVAnn
</span><a href="#local-6989586621680962348"><span class="hs-identifier hs-var">fvs</span></a></span><span> </span><span class="hs-comment">-- Max over Ids only; the</span><span>
</span><span id="line-1467"></span><span>                                              </span><span class="hs-comment">-- tyvars will be abstracted</span><span>
</span><span id="line-1468"></span><span>
</span><span id="line-1469"></span><span>    </span><span id="local-6989586621680962341"><span class="annot"><span class="annottext">as_far_as_poss :: Level
</span><a href="#local-6989586621680962341"><span class="hs-identifier hs-var hs-var">as_far_as_poss</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Bool) -&gt; LevelEnv -&gt; TyCoVarSet -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#maxFvLevel%27"><span class="hs-identifier hs-var">maxFvLevel'</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isId"><span class="hs-identifier hs-var">isId</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962349"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVarSet
</span><a href="#local-6989586621680962347"><span class="hs-identifier hs-var">fvs_ty</span></a></span><span>
</span><span id="line-1470"></span><span>                     </span><span class="hs-comment">-- See Note [Floating and kind casts]</span><span>
</span><span id="line-1471"></span><span>
</span><span id="line-1472"></span><span class="hs-comment">{- Note [Floating and kind casts]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider this
   case x of
     K (co :: * ~# k) -&gt; let v :: Int |&gt; co
                             v = e
                         in blah

Then, even if we are abstracting over Ids, or if e is bottom, we can't
float v outside the 'co' binding.  Reason: if we did we'd get
    v' :: forall k. (Int ~# Age) =&gt; Int |&gt; co
and now 'co' isn't in scope in that type. The underlying reason is
that 'co' is a value-level thing and we can't abstract over that in a
type (else we'd get a dependent type).  So if v's /type/ mentions 'co'
we can't float it out beyond the binding site of 'co'.

That's why we have this as_far_as_poss stuff.  Usually as_far_as_poss
is just tOP_LEVEL; but occasionally a coercion variable (which is an
Id) mentioned in type prevents this.

Example #14270 comment:15.
-}</span><span>
</span><span id="line-1494"></span><span>
</span><span id="line-1495"></span><span>
</span><span id="line-1496"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#isFunction"><span class="hs-identifier hs-type">isFunction</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.FVs.html#CoreExprWithFVs"><span class="hs-identifier hs-type">CoreExprWithFVs</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1497"></span><span class="hs-comment">-- The idea here is that we want to float *functions* to</span><span>
</span><span id="line-1498"></span><span class="hs-comment">-- the top level.  This saves no work, but</span><span>
</span><span id="line-1499"></span><span class="hs-comment">--      (a) it can make the host function body a lot smaller,</span><span>
</span><span id="line-1500"></span><span class="hs-comment">--              and hence inlinable.</span><span>
</span><span id="line-1501"></span><span class="hs-comment">--      (b) it can also save allocation when the function is recursive:</span><span>
</span><span id="line-1502"></span><span class="hs-comment">--          h = \x -&gt; letrec f = \y -&gt; ...f...y...x...</span><span>
</span><span id="line-1503"></span><span class="hs-comment">--                    in f x</span><span>
</span><span id="line-1504"></span><span class="hs-comment">--     becomes</span><span>
</span><span id="line-1505"></span><span class="hs-comment">--          f = \x y -&gt; ...(f x)...y...x...</span><span>
</span><span id="line-1506"></span><span class="hs-comment">--          h = \x -&gt; f x x</span><span>
</span><span id="line-1507"></span><span class="hs-comment">--     No allocation for f now.</span><span>
</span><span id="line-1508"></span><span class="hs-comment">-- We may only want to do this if there are sufficiently few free</span><span>
</span><span id="line-1509"></span><span class="hs-comment">-- variables.  We certainly only want to do it for values, and not for</span><span>
</span><span id="line-1510"></span><span class="hs-comment">-- constructors.  So the simple thing is just to look for lambdas</span><span>
</span><span id="line-1511"></span><span id="isFunction"><span class="annot"><span class="annottext">isFunction :: CoreExprWithFVs -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#isFunction"><span class="hs-identifier hs-var hs-var">isFunction</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FVAnn
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#AnnLam"><span class="hs-identifier hs-type">AnnLam</span></a></span><span> </span><span id="local-6989586621680962335"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962335"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span id="local-6989586621680962334"><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962334"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isId"><span class="hs-identifier hs-var">isId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962335"><span class="hs-identifier hs-var">b</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-1512"></span><span>                           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#isFunction"><span class="hs-identifier hs-var">isFunction</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><a href="#local-6989586621680962334"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-1513"></span><span class="hs-comment">-- isFunction (_, AnnTick _ e)         = isFunction e  -- dubious</span><span>
</span><span id="line-1514"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#isFunction"><span class="hs-identifier hs-var">isFunction</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExprWithFVs
</span><span class="hs-identifier">_</span></span><span>                           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1515"></span><span>
</span><span id="line-1516"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#countFreeIds"><span class="hs-identifier hs-type">countFreeIds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#DVarSet"><span class="hs-identifier hs-type">DVarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-1517"></span><span id="countFreeIds"><span class="annot"><span class="annottext">countFreeIds :: FVAnn -&gt; Int
</span><a href="GHC.Core.Opt.SetLevels.html#countFreeIds"><span class="hs-identifier hs-var hs-var">countFreeIds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Int -&gt; Int) -&gt; Int -&gt; UniqDFM Id Id -&gt; Int
forall elt a key. (elt -&gt; a -&gt; a) -&gt; a -&gt; UniqDFM key elt -&gt; a
</span><a href="GHC.Types.Unique.DFM.html#nonDetStrictFoldUDFM"><span class="hs-identifier hs-var">nonDetStrictFoldUDFM</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Int -&gt; Int
</span><a href="#local-6989586621680962332"><span class="hs-identifier hs-var">add</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">(UniqDFM Id Id -&gt; Int) -&gt; (FVAnn -&gt; UniqDFM Id Id) -&gt; FVAnn -&gt; Int
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">FVAnn -&gt; UniqDFM Id Id
forall a. UniqDSet a -&gt; UniqDFM a a
</span><a href="GHC.Types.Unique.DSet.html#getUniqDSet"><span class="hs-identifier hs-var">getUniqDSet</span></a></span><span>
</span><span id="line-1518"></span><span>  </span><span class="hs-comment">-- It's OK to use nonDetStrictFoldUDFM here because we're just counting things.</span><span>
</span><span id="line-1519"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1520"></span><span>    </span><span class="annot"><a href="#local-6989586621680962332"><span class="hs-identifier hs-type">add</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-1521"></span><span>    </span><span id="local-6989586621680962332"><span class="annot"><span class="annottext">add :: Id -&gt; Int -&gt; Int
</span><a href="#local-6989586621680962332"><span class="hs-identifier hs-var hs-var">add</span></a></span></span><span> </span><span id="local-6989586621680962331"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962331"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span id="local-6989586621680962330"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962330"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isId"><span class="hs-identifier hs-var">isId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962331"><span class="hs-identifier hs-var">v</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962330"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span>
</span><span id="line-1522"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962330"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-1523"></span><span>
</span><span id="line-1524"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
\subsection{Free-To-Level Monad}
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-1531"></span><span>
</span><span id="line-1532"></span><span class="hs-keyword">data</span><span> </span><span id="LevelEnv"><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-var">LevelEnv</span></a></span></span><span>
</span><span id="line-1533"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="LE"><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LE"><span class="hs-identifier hs-var">LE</span></a></span></span><span> </span><span class="hs-special">{</span><span> </span><span id="le_switches"><span class="annot"><span class="annottext">LevelEnv -&gt; FloatOutSwitches
</span><a href="GHC.Core.Opt.SetLevels.html#le_switches"><span class="hs-identifier hs-var hs-var">le_switches</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Monad.html#FloatOutSwitches"><span class="hs-identifier hs-type">FloatOutSwitches</span></a></span><span>
</span><span id="line-1534"></span><span>       </span><span class="hs-special">,</span><span> </span><span id="le_ctxt_lvl"><span class="annot"><span class="annottext">LevelEnv -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#le_ctxt_lvl"><span class="hs-identifier hs-var hs-var">le_ctxt_lvl</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span>           </span><span class="hs-comment">-- The current level</span><span>
</span><span id="line-1535"></span><span>       </span><span class="hs-special">,</span><span> </span><span id="le_lvl_env"><span class="annot"><span class="annottext">LevelEnv -&gt; VarEnv Level
</span><a href="GHC.Core.Opt.SetLevels.html#le_lvl_env"><span class="hs-identifier hs-var hs-var">le_lvl_env</span></a></span></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#VarEnv"><span class="hs-identifier hs-type">VarEnv</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span>    </span><span class="hs-comment">-- Domain is *post-cloned* TyVars and Ids</span><span>
</span><span id="line-1536"></span><span>       </span><span class="hs-special">,</span><span> </span><span id="le_join_ceil"><span class="annot"><span class="annottext">LevelEnv -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#le_join_ceil"><span class="hs-identifier hs-var hs-var">le_join_ceil</span></a></span></span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span>           </span><span class="hs-comment">-- Highest level to which joins float</span><span>
</span><span id="line-1537"></span><span>                                        </span><span class="hs-comment">-- Invariant: always &gt;= le_ctxt_lvl</span><span>
</span><span id="line-1538"></span><span>
</span><span id="line-1539"></span><span>       </span><span class="hs-comment">-- See Note [le_subst and le_env]</span><span>
</span><span id="line-1540"></span><span>       </span><span class="hs-special">,</span><span> </span><span id="le_subst"><span class="annot"><span class="annottext">LevelEnv -&gt; Subst
</span><a href="GHC.Core.Opt.SetLevels.html#le_subst"><span class="hs-identifier hs-var hs-var">le_subst</span></a></span></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span>           </span><span class="hs-comment">-- Domain is pre-cloned TyVars and Ids</span><span>
</span><span id="line-1541"></span><span>                                        </span><span class="hs-comment">-- The Id -&gt; CoreExpr in the Subst is ignored</span><span>
</span><span id="line-1542"></span><span>                                        </span><span class="hs-comment">-- (since we want to substitute a LevelledExpr for</span><span>
</span><span id="line-1543"></span><span>                                        </span><span class="hs-comment">-- an Id via le_env) but we do use the Co/TyVar substs</span><span>
</span><span id="line-1544"></span><span>       </span><span class="hs-special">,</span><span> </span><span id="le_env"><span class="annot"><span class="annottext">LevelEnv -&gt; IdEnv ([Id], LevelledExpr)
</span><a href="GHC.Core.Opt.SetLevels.html#le_env"><span class="hs-identifier hs-var hs-var">le_env</span></a></span></span><span>      </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#IdEnv"><span class="hs-identifier hs-type">IdEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#OutVar"><span class="hs-identifier hs-type">OutVar</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelledExpr"><span class="hs-identifier hs-type">LevelledExpr</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- Domain is pre-cloned Ids</span><span>
</span><span id="line-1545"></span><span>    </span><span class="hs-special">}</span><span>
</span><span id="line-1546"></span><span>
</span><span id="line-1547"></span><span class="hs-comment">{- Note [le_subst and le_env]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We clone let- and case-bound variables so that they are still distinct
when floated out; hence the le_subst/le_env.  (see point 3 of the
module overview comment).  We also use these envs when making a
variable polymorphic because we want to float it out past a big
lambda.

The le_subst and le_env always implement the same mapping,
     in_x :-&gt;  out_x a b
where out_x is an OutVar, and a,b are its arguments (when
we perform abstraction at the same time as floating).

  le_subst maps to CoreExpr
  le_env   maps to LevelledExpr

Since the range is always a variable or application, there is never
any difference between the two, but sadly the types differ.  The
le_subst is used when substituting in a variable's IdInfo; the le_env
when we find a Var.

In addition the le_env records a [OutVar] of variables free in the
OutExpr/LevelledExpr, just so we don't have to call freeVars
repeatedly.  This list is always non-empty, and the first element is
out_x

The domain of the both envs is *pre-cloned* Ids, though

The domain of the le_lvl_env is the *post-cloned* Ids
-}</span><span>
</span><span id="line-1577"></span><span>
</span><span id="line-1578"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#initialEnv"><span class="hs-identifier hs-type">initialEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Monad.html#FloatOutSwitches"><span class="hs-identifier hs-type">FloatOutSwitches</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span>
</span><span id="line-1579"></span><span id="initialEnv"><span class="annot"><span class="annottext">initialEnv :: FloatOutSwitches -&gt; LevelEnv
</span><a href="GHC.Core.Opt.SetLevels.html#initialEnv"><span class="hs-identifier hs-var hs-var">initialEnv</span></a></span></span><span> </span><span id="local-6989586621680962328"><span class="annot"><span class="annottext">FloatOutSwitches
</span><a href="#local-6989586621680962328"><span class="hs-identifier hs-var">float_lams</span></a></span></span><span>
</span><span id="line-1580"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LE :: FloatOutSwitches
-&gt; Level
-&gt; VarEnv Level
-&gt; Level
-&gt; Subst
-&gt; IdEnv ([Id], LevelledExpr)
-&gt; LevelEnv
</span><a href="GHC.Core.Opt.SetLevels.html#LE"><span class="hs-identifier hs-type">LE</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">le_switches :: FloatOutSwitches
</span><a href="GHC.Core.Opt.SetLevels.html#le_switches"><span class="hs-identifier hs-var">le_switches</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FloatOutSwitches
</span><a href="#local-6989586621680962328"><span class="hs-identifier hs-var">float_lams</span></a></span><span>
</span><span id="line-1581"></span><span>       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">le_ctxt_lvl :: Level
</span><a href="GHC.Core.Opt.SetLevels.html#le_ctxt_lvl"><span class="hs-identifier hs-var">le_ctxt_lvl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="GHC.Core.Opt.SetLevels.html#tOP_LEVEL"><span class="hs-identifier hs-var">tOP_LEVEL</span></a></span><span>
</span><span id="line-1582"></span><span>       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">le_join_ceil :: Level
</span><a href="GHC.Core.Opt.SetLevels.html#le_join_ceil"><span class="hs-identifier hs-var">le_join_ceil</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; Level
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#panic"><span class="hs-identifier hs-var">panic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;initialEnv&quot;</span></span><span>
</span><span id="line-1583"></span><span>       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">le_lvl_env :: VarEnv Level
</span><a href="GHC.Core.Opt.SetLevels.html#le_lvl_env"><span class="hs-identifier hs-var">le_lvl_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarEnv Level
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span>
</span><span id="line-1584"></span><span>       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">le_subst :: Subst
</span><a href="GHC.Core.Opt.SetLevels.html#le_subst"><span class="hs-identifier hs-var">le_subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="GHC.Core.Subst.html#emptySubst"><span class="hs-identifier hs-var">emptySubst</span></a></span><span>
</span><span id="line-1585"></span><span>       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">le_env :: IdEnv ([Id], LevelledExpr)
</span><a href="GHC.Core.Opt.SetLevels.html#le_env"><span class="hs-identifier hs-var">le_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdEnv ([Id], LevelledExpr)
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1586"></span><span>
</span><span id="line-1587"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#addLvl"><span class="hs-identifier hs-type">addLvl</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#VarEnv"><span class="hs-identifier hs-type">VarEnv</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#OutVar"><span class="hs-identifier hs-type">OutVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#VarEnv"><span class="hs-identifier hs-type">VarEnv</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span>
</span><span id="line-1588"></span><span id="addLvl"><span class="annot"><span class="annottext">addLvl :: Level -&gt; VarEnv Level -&gt; Id -&gt; VarEnv Level
</span><a href="GHC.Core.Opt.SetLevels.html#addLvl"><span class="hs-identifier hs-var hs-var">addLvl</span></a></span></span><span> </span><span id="local-6989586621680962324"><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962324"><span class="hs-identifier hs-var">dest_lvl</span></a></span></span><span> </span><span id="local-6989586621680962323"><span class="annot"><span class="annottext">VarEnv Level
</span><a href="#local-6989586621680962323"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680962322"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962322"><span class="hs-identifier hs-var">v'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarEnv Level -&gt; Id -&gt; Level -&gt; VarEnv Level
forall a. VarEnv a -&gt; Id -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">VarEnv Level
</span><a href="#local-6989586621680962323"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962322"><span class="hs-identifier hs-var">v'</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962324"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span>
</span><span id="line-1589"></span><span>
</span><span id="line-1590"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#addLvls"><span class="hs-identifier hs-type">addLvls</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#VarEnv"><span class="hs-identifier hs-type">VarEnv</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#OutVar"><span class="hs-identifier hs-type">OutVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#VarEnv"><span class="hs-identifier hs-type">VarEnv</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span>
</span><span id="line-1591"></span><span id="addLvls"><span class="annot"><span class="annottext">addLvls :: Level -&gt; VarEnv Level -&gt; [Id] -&gt; VarEnv Level
</span><a href="GHC.Core.Opt.SetLevels.html#addLvls"><span class="hs-identifier hs-var hs-var">addLvls</span></a></span></span><span> </span><span id="local-6989586621680962320"><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962320"><span class="hs-identifier hs-var">dest_lvl</span></a></span></span><span> </span><span id="local-6989586621680962319"><span class="annot"><span class="annottext">VarEnv Level
</span><a href="#local-6989586621680962319"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680962318"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962318"><span class="hs-identifier hs-var">vs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(VarEnv Level -&gt; Id -&gt; VarEnv Level)
-&gt; VarEnv Level -&gt; [Id] -&gt; VarEnv Level
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Level -&gt; VarEnv Level -&gt; Id -&gt; VarEnv Level
</span><a href="GHC.Core.Opt.SetLevels.html#addLvl"><span class="hs-identifier hs-var">addLvl</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962320"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">VarEnv Level
</span><a href="#local-6989586621680962319"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962318"><span class="hs-identifier hs-var">vs</span></a></span><span>
</span><span id="line-1592"></span><span>
</span><span id="line-1593"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#floatLams"><span class="hs-identifier hs-type">floatLams</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-1594"></span><span id="floatLams"><span class="annot"><span class="annottext">floatLams :: LevelEnv -&gt; Maybe Int
</span><a href="GHC.Core.Opt.SetLevels.html#floatLams"><span class="hs-identifier hs-var hs-var">floatLams</span></a></span></span><span> </span><span id="local-6989586621680962317"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962317"><span class="hs-identifier hs-var">le</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FloatOutSwitches -&gt; Maybe Int
</span><a href="GHC.Core.Opt.Monad.html#floatOutLambdas"><span class="hs-identifier hs-var hs-var">floatOutLambdas</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; FloatOutSwitches
</span><a href="GHC.Core.Opt.SetLevels.html#le_switches"><span class="hs-identifier hs-var hs-var">le_switches</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962317"><span class="hs-identifier hs-var">le</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1595"></span><span>
</span><span id="line-1596"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#floatConsts"><span class="hs-identifier hs-type">floatConsts</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1597"></span><span id="floatConsts"><span class="annot"><span class="annottext">floatConsts :: LevelEnv -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#floatConsts"><span class="hs-identifier hs-var hs-var">floatConsts</span></a></span></span><span> </span><span id="local-6989586621680962315"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962315"><span class="hs-identifier hs-var">le</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FloatOutSwitches -&gt; Bool
</span><a href="GHC.Core.Opt.Monad.html#floatOutConstants"><span class="hs-identifier hs-var hs-var">floatOutConstants</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; FloatOutSwitches
</span><a href="GHC.Core.Opt.SetLevels.html#le_switches"><span class="hs-identifier hs-var hs-var">le_switches</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962315"><span class="hs-identifier hs-var">le</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1598"></span><span>
</span><span id="line-1599"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#floatOverSat"><span class="hs-identifier hs-type">floatOverSat</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1600"></span><span id="floatOverSat"><span class="annot"><span class="annottext">floatOverSat :: LevelEnv -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#floatOverSat"><span class="hs-identifier hs-var hs-var">floatOverSat</span></a></span></span><span> </span><span id="local-6989586621680962313"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962313"><span class="hs-identifier hs-var">le</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FloatOutSwitches -&gt; Bool
</span><a href="GHC.Core.Opt.Monad.html#floatOutOverSatApps"><span class="hs-identifier hs-var hs-var">floatOutOverSatApps</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; FloatOutSwitches
</span><a href="GHC.Core.Opt.SetLevels.html#le_switches"><span class="hs-identifier hs-var hs-var">le_switches</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962313"><span class="hs-identifier hs-var">le</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1601"></span><span>
</span><span id="line-1602"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#floatTopLvlOnly"><span class="hs-identifier hs-type">floatTopLvlOnly</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1603"></span><span id="floatTopLvlOnly"><span class="annot"><span class="annottext">floatTopLvlOnly :: LevelEnv -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#floatTopLvlOnly"><span class="hs-identifier hs-var hs-var">floatTopLvlOnly</span></a></span></span><span> </span><span id="local-6989586621680962311"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962311"><span class="hs-identifier hs-var">le</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FloatOutSwitches -&gt; Bool
</span><a href="GHC.Core.Opt.Monad.html#floatToTopLevelOnly"><span class="hs-identifier hs-var hs-var">floatToTopLevelOnly</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; FloatOutSwitches
</span><a href="GHC.Core.Opt.SetLevels.html#le_switches"><span class="hs-identifier hs-var hs-var">le_switches</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962311"><span class="hs-identifier hs-var">le</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1604"></span><span>
</span><span id="line-1605"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#incMinorLvlFrom"><span class="hs-identifier hs-type">incMinorLvlFrom</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span>
</span><span id="line-1606"></span><span id="incMinorLvlFrom"><span class="annot"><span class="annottext">incMinorLvlFrom :: LevelEnv -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#incMinorLvlFrom"><span class="hs-identifier hs-var hs-var">incMinorLvlFrom</span></a></span></span><span> </span><span id="local-6989586621680962309"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962309"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#incMinorLvl"><span class="hs-identifier hs-var">incMinorLvl</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#le_ctxt_lvl"><span class="hs-identifier hs-var hs-var">le_ctxt_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962309"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1607"></span><span>
</span><span id="line-1608"></span><span class="hs-comment">-- extendCaseBndrEnv adds the mapping case-bndr-&gt;scrut-var if it can</span><span>
</span><span id="line-1609"></span><span class="hs-comment">-- See Note [Binder-swap during float-out]</span><span>
</span><span id="line-1610"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#extendCaseBndrEnv"><span class="hs-identifier hs-type">extendCaseBndrEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span>
</span><span id="line-1611"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>                 </span><span class="hs-comment">-- Pre-cloned case binder</span><span>
</span><span id="line-1612"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#Expr"><span class="hs-identifier hs-type">Expr</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelledBndr"><span class="hs-identifier hs-type">LevelledBndr</span></a></span><span>  </span><span class="hs-comment">-- Post-cloned scrutinee</span><span>
</span><span id="line-1613"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span>
</span><span id="line-1614"></span><span id="extendCaseBndrEnv"><span class="annot"><span class="annottext">extendCaseBndrEnv :: LevelEnv -&gt; Id -&gt; LevelledExpr -&gt; LevelEnv
</span><a href="GHC.Core.Opt.SetLevels.html#extendCaseBndrEnv"><span class="hs-identifier hs-var hs-var">extendCaseBndrEnv</span></a></span></span><span> </span><span id="local-6989586621680962308"><span class="annot"><span class="annottext">le :: LevelEnv
</span><a href="#local-6989586621680962308"><span class="hs-identifier hs-var">le</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LE"><span class="hs-identifier hs-type">LE</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">le_subst :: LevelEnv -&gt; Subst
</span><a href="GHC.Core.Opt.SetLevels.html#le_subst"><span class="hs-identifier hs-var">le_subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680962307"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680962307"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">le_env :: LevelEnv -&gt; IdEnv ([Id], LevelledExpr)
</span><a href="GHC.Core.Opt.SetLevels.html#le_env"><span class="hs-identifier hs-var">le_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680962306"><span class="annot"><span class="annottext">IdEnv ([Id], LevelledExpr)
</span><a href="#local-6989586621680962306"><span class="hs-identifier hs-var">id_env</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1615"></span><span>                  </span><span id="local-6989586621680962305"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962305"><span class="hs-identifier hs-var">case_bndr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span id="local-6989586621680962304"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962304"><span class="hs-identifier hs-var">scrut_var</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1616"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Core.Type.html#Many"><span class="hs-identifier hs-var">Many</span></a></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Types.Var.html#varMult"><span class="hs-identifier hs-var hs-var">varMult</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962305"><span class="hs-identifier hs-var">case_bndr</span></a></span><span>
</span><span id="line-1617"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962308"><span class="hs-identifier hs-var">le</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">le_subst :: Subst
</span><a href="GHC.Core.Opt.SetLevels.html#le_subst"><span class="hs-identifier hs-var">le_subst</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; Id -&gt; Id -&gt; Subst
</span><a href="GHC.Core.Subst.html#extendSubstWithVar"><span class="hs-identifier hs-var">extendSubstWithVar</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680962307"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962305"><span class="hs-identifier hs-var">case_bndr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962304"><span class="hs-identifier hs-var">scrut_var</span></a></span><span>
</span><span id="line-1618"></span><span>       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">le_env :: IdEnv ([Id], LevelledExpr)
</span><a href="GHC.Core.Opt.SetLevels.html#le_env"><span class="hs-identifier hs-var">le_env</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdEnv ([Id], LevelledExpr)
-&gt; (Id, Id) -&gt; IdEnv ([Id], LevelledExpr)
</span><a href="GHC.Core.Opt.SetLevels.html#add_id"><span class="hs-identifier hs-var">add_id</span></a></span><span> </span><span class="annot"><span class="annottext">IdEnv ([Id], LevelledExpr)
</span><a href="#local-6989586621680962306"><span class="hs-identifier hs-var">id_env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962305"><span class="hs-identifier hs-var">case_bndr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962304"><span class="hs-identifier hs-var">scrut_var</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1619"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#extendCaseBndrEnv"><span class="hs-identifier hs-var">extendCaseBndrEnv</span></a></span><span> </span><span id="local-6989586621680962301"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962301"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="annot"><span class="annottext">Id
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962301"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-1620"></span><span>
</span><span id="line-1621"></span><span class="hs-comment">-- See Note [Join ceiling]</span><span>
</span><span id="line-1622"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#placeJoinCeiling"><span class="hs-identifier hs-type">placeJoinCeiling</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span>
</span><span id="line-1623"></span><span id="placeJoinCeiling"><span class="annot"><span class="annottext">placeJoinCeiling :: LevelEnv -&gt; LevelEnv
</span><a href="GHC.Core.Opt.SetLevels.html#placeJoinCeiling"><span class="hs-identifier hs-var hs-var">placeJoinCeiling</span></a></span></span><span> </span><span id="local-6989586621680962300"><span class="annot"><span class="annottext">le :: LevelEnv
</span><a href="#local-6989586621680962300"><span class="hs-identifier hs-var">le</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LE"><span class="hs-identifier hs-type">LE</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">le_ctxt_lvl :: LevelEnv -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#le_ctxt_lvl"><span class="hs-identifier hs-var">le_ctxt_lvl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680962299"><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962299"><span class="hs-identifier hs-var">lvl</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1624"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962300"><span class="hs-identifier hs-var">le</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">le_ctxt_lvl :: Level
</span><a href="GHC.Core.Opt.SetLevels.html#le_ctxt_lvl"><span class="hs-identifier hs-var">le_ctxt_lvl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962298"><span class="hs-identifier hs-var">lvl'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">le_join_ceil :: Level
</span><a href="GHC.Core.Opt.SetLevels.html#le_join_ceil"><span class="hs-identifier hs-var">le_join_ceil</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962298"><span class="hs-identifier hs-var">lvl'</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1625"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1626"></span><span>    </span><span id="local-6989586621680962298"><span class="annot"><span class="annottext">lvl' :: Level
</span><a href="#local-6989586621680962298"><span class="hs-identifier hs-var hs-var">lvl'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#asJoinCeilLvl"><span class="hs-identifier hs-var">asJoinCeilLvl</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Level -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#incMinorLvl"><span class="hs-identifier hs-var">incMinorLvl</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962299"><span class="hs-identifier hs-var">lvl</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1627"></span><span>
</span><span id="line-1628"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#maxFvLevel"><span class="hs-identifier hs-type">maxFvLevel</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#DVarSet"><span class="hs-identifier hs-type">DVarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span>
</span><span id="line-1629"></span><span id="maxFvLevel"><span class="annot"><span class="annottext">maxFvLevel :: (Id -&gt; Bool) -&gt; LevelEnv -&gt; FVAnn -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#maxFvLevel"><span class="hs-identifier hs-var hs-var">maxFvLevel</span></a></span></span><span> </span><span id="local-6989586621680962297"><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="#local-6989586621680962297"><span class="hs-identifier hs-var">max_me</span></a></span></span><span> </span><span id="local-6989586621680962296"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962296"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680962295"><span class="annot"><span class="annottext">FVAnn
</span><a href="#local-6989586621680962295"><span class="hs-identifier hs-var">var_set</span></a></span></span><span>
</span><span id="line-1630"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Level -&gt; Level) -&gt; Level -&gt; FVAnn -&gt; Level
forall a. (Id -&gt; a -&gt; a) -&gt; a -&gt; FVAnn -&gt; a
</span><a href="GHC.Types.Var.Set.html#nonDetStrictFoldDVarSet"><span class="hs-identifier hs-var">nonDetStrictFoldDVarSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Id -&gt; Bool) -&gt; LevelEnv -&gt; Id -&gt; Level -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#maxIn"><span class="hs-identifier hs-var">maxIn</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="#local-6989586621680962297"><span class="hs-identifier hs-var">max_me</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962296"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="GHC.Core.Opt.SetLevels.html#tOP_LEVEL"><span class="hs-identifier hs-var">tOP_LEVEL</span></a></span><span> </span><span class="annot"><span class="annottext">FVAnn
</span><a href="#local-6989586621680962295"><span class="hs-identifier hs-var">var_set</span></a></span><span>
</span><span id="line-1631"></span><span>    </span><span class="hs-comment">-- It's OK to use a non-deterministic fold here because maxIn commutes.</span><span>
</span><span id="line-1632"></span><span>
</span><span id="line-1633"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#maxFvLevel%27"><span class="hs-identifier hs-type">maxFvLevel'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#TyCoVarSet"><span class="hs-identifier hs-type">TyCoVarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span>
</span><span id="line-1634"></span><span class="hs-comment">-- Same but for TyCoVarSet</span><span>
</span><span id="line-1635"></span><span id="maxFvLevel%27"><span class="annot"><span class="annottext">maxFvLevel' :: (Id -&gt; Bool) -&gt; LevelEnv -&gt; TyCoVarSet -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#maxFvLevel%27"><span class="hs-identifier hs-var hs-var">maxFvLevel'</span></a></span></span><span> </span><span id="local-6989586621680962292"><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="#local-6989586621680962292"><span class="hs-identifier hs-var">max_me</span></a></span></span><span> </span><span id="local-6989586621680962291"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962291"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680962290"><span class="annot"><span class="annottext">TyCoVarSet
</span><a href="#local-6989586621680962290"><span class="hs-identifier hs-var">var_set</span></a></span></span><span>
</span><span id="line-1636"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Level -&gt; Level) -&gt; Level -&gt; TyCoVarSet -&gt; Level
forall elt a. (elt -&gt; a -&gt; a) -&gt; a -&gt; UniqSet elt -&gt; a
</span><a href="GHC.Types.Unique.Set.html#nonDetStrictFoldUniqSet"><span class="hs-identifier hs-var">nonDetStrictFoldUniqSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Id -&gt; Bool) -&gt; LevelEnv -&gt; Id -&gt; Level -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#maxIn"><span class="hs-identifier hs-var">maxIn</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="#local-6989586621680962292"><span class="hs-identifier hs-var">max_me</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962291"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="GHC.Core.Opt.SetLevels.html#tOP_LEVEL"><span class="hs-identifier hs-var">tOP_LEVEL</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVarSet
</span><a href="#local-6989586621680962290"><span class="hs-identifier hs-var">var_set</span></a></span><span>
</span><span id="line-1637"></span><span>    </span><span class="hs-comment">-- It's OK to use a non-deterministic fold here because maxIn commutes.</span><span>
</span><span id="line-1638"></span><span>
</span><span id="line-1639"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#maxIn"><span class="hs-identifier hs-type">maxIn</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#InVar"><span class="hs-identifier hs-type">InVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span>
</span><span id="line-1640"></span><span id="maxIn"><span class="annot"><span class="annottext">maxIn :: (Id -&gt; Bool) -&gt; LevelEnv -&gt; Id -&gt; Level -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#maxIn"><span class="hs-identifier hs-var hs-var">maxIn</span></a></span></span><span> </span><span id="local-6989586621680962289"><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="#local-6989586621680962289"><span class="hs-identifier hs-var">max_me</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LE"><span class="hs-identifier hs-type">LE</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">le_lvl_env :: LevelEnv -&gt; VarEnv Level
</span><a href="GHC.Core.Opt.SetLevels.html#le_lvl_env"><span class="hs-identifier hs-var">le_lvl_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680962288"><span class="annot"><span class="annottext">VarEnv Level
</span><a href="#local-6989586621680962288"><span class="hs-identifier hs-var">lvl_env</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">le_env :: LevelEnv -&gt; IdEnv ([Id], LevelledExpr)
</span><a href="GHC.Core.Opt.SetLevels.html#le_env"><span class="hs-identifier hs-var">le_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680962287"><span class="annot"><span class="annottext">IdEnv ([Id], LevelledExpr)
</span><a href="#local-6989586621680962287"><span class="hs-identifier hs-var">id_env</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621680962286"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962286"><span class="hs-identifier hs-var">in_var</span></a></span></span><span> </span><span id="local-6989586621680962285"><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962285"><span class="hs-identifier hs-var">lvl</span></a></span></span><span>
</span><span id="line-1641"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">IdEnv ([Id], LevelledExpr) -&gt; Id -&gt; Maybe ([Id], LevelledExpr)
forall a. VarEnv a -&gt; Id -&gt; Maybe a
</span><a href="GHC.Types.Var.Env.html#lookupVarEnv"><span class="hs-identifier hs-var">lookupVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">IdEnv ([Id], LevelledExpr)
</span><a href="#local-6989586621680962287"><span class="hs-identifier hs-var">id_env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962286"><span class="hs-identifier hs-var">in_var</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1642"></span><span>      </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680962283"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962283"><span class="hs-identifier hs-var">abs_vars</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Level -&gt; Level) -&gt; Level -&gt; [Id] -&gt; Level
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Level -&gt; Level
</span><a href="#local-6989586621680962282"><span class="hs-identifier hs-var">max_out</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962285"><span class="hs-identifier hs-var">lvl</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962283"><span class="hs-identifier hs-var">abs_vars</span></a></span><span>
</span><span id="line-1643"></span><span>      </span><span class="annot"><span class="annottext">Maybe ([Id], LevelledExpr)
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Level -&gt; Level
</span><a href="#local-6989586621680962282"><span class="hs-identifier hs-var">max_out</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962286"><span class="hs-identifier hs-var">in_var</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962285"><span class="hs-identifier hs-var">lvl</span></a></span><span>
</span><span id="line-1644"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1645"></span><span>    </span><span id="local-6989586621680962282"><span class="annot"><span class="annottext">max_out :: Id -&gt; Level -&gt; Level
</span><a href="#local-6989586621680962282"><span class="hs-identifier hs-var hs-var">max_out</span></a></span></span><span> </span><span id="local-6989586621680962281"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962281"><span class="hs-identifier hs-var">out_var</span></a></span></span><span> </span><span id="local-6989586621680962280"><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962280"><span class="hs-identifier hs-var">lvl</span></a></span></span><span>
</span><span id="line-1646"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="#local-6989586621680962289"><span class="hs-identifier hs-var">max_me</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962281"><span class="hs-identifier hs-var">out_var</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">VarEnv Level -&gt; Id -&gt; Maybe Level
forall a. VarEnv a -&gt; Id -&gt; Maybe a
</span><a href="GHC.Types.Var.Env.html#lookupVarEnv"><span class="hs-identifier hs-var">lookupVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">VarEnv Level
</span><a href="#local-6989586621680962288"><span class="hs-identifier hs-var">lvl_env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962281"><span class="hs-identifier hs-var">out_var</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1647"></span><span>                                </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680962279"><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962279"><span class="hs-identifier hs-var">lvl'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Level -&gt; Level -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#maxLvl"><span class="hs-identifier hs-var">maxLvl</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962279"><span class="hs-identifier hs-var">lvl'</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962280"><span class="hs-identifier hs-var">lvl</span></a></span><span>
</span><span id="line-1648"></span><span>                                </span><span class="annot"><span class="annottext">Maybe Level
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962280"><span class="hs-identifier hs-var">lvl</span></a></span><span>
</span><span id="line-1649"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962280"><span class="hs-identifier hs-var">lvl</span></a></span><span>       </span><span class="hs-comment">-- Ignore some vars depending on max_me</span><span>
</span><span id="line-1650"></span><span>
</span><span id="line-1651"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#lookupVar"><span class="hs-identifier hs-type">lookupVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelledExpr"><span class="hs-identifier hs-type">LevelledExpr</span></a></span><span>
</span><span id="line-1652"></span><span id="lookupVar"><span class="annot"><span class="annottext">lookupVar :: LevelEnv -&gt; Id -&gt; LevelledExpr
</span><a href="GHC.Core.Opt.SetLevels.html#lookupVar"><span class="hs-identifier hs-var hs-var">lookupVar</span></a></span></span><span> </span><span id="local-6989586621680962278"><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962278"><span class="hs-identifier hs-var">le</span></a></span></span><span> </span><span id="local-6989586621680962277"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962277"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">IdEnv ([Id], LevelledExpr) -&gt; Id -&gt; Maybe ([Id], LevelledExpr)
forall a. VarEnv a -&gt; Id -&gt; Maybe a
</span><a href="GHC.Types.Var.Env.html#lookupVarEnv"><span class="hs-identifier hs-var">lookupVarEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv -&gt; IdEnv ([Id], LevelledExpr)
</span><a href="GHC.Core.Opt.SetLevels.html#le_env"><span class="hs-identifier hs-var hs-var">le_env</span></a></span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962278"><span class="hs-identifier hs-var">le</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962277"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1653"></span><span>                    </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962276"><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962276"><span class="hs-identifier hs-var">expr</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962276"><span class="hs-identifier hs-var">expr</span></a></span><span>
</span><span id="line-1654"></span><span>                    </span><span class="annot"><span class="annottext">Maybe ([Id], LevelledExpr)
</span><span class="hs-identifier">_</span></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Id -&gt; LevelledExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962277"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-1655"></span><span>
</span><span id="line-1656"></span><span class="hs-comment">-- Level to which join points are allowed to float (boundary of current tail</span><span>
</span><span id="line-1657"></span><span class="hs-comment">-- context). See Note [Join ceiling]</span><span>
</span><span id="line-1658"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#joinCeilingLevel"><span class="hs-identifier hs-type">joinCeilingLevel</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span>
</span><span id="line-1659"></span><span id="joinCeilingLevel"><span class="annot"><span class="annottext">joinCeilingLevel :: LevelEnv -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#joinCeilingLevel"><span class="hs-identifier hs-var hs-var">joinCeilingLevel</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelEnv -&gt; Level
</span><a href="GHC.Core.Opt.SetLevels.html#le_join_ceil"><span class="hs-identifier hs-var hs-var">le_join_ceil</span></a></span><span>
</span><span id="line-1660"></span><span>
</span><span id="line-1661"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#abstractVars"><span class="hs-identifier hs-type">abstractVars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#DVarSet"><span class="hs-identifier hs-type">DVarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#OutVar"><span class="hs-identifier hs-type">OutVar</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1662"></span><span>        </span><span class="hs-comment">-- Find the variables in fvs, free vars of the target expression,</span><span>
</span><span id="line-1663"></span><span>        </span><span class="hs-comment">-- whose level is greater than the destination level</span><span>
</span><span id="line-1664"></span><span>        </span><span class="hs-comment">-- These are the ones we are going to abstract out</span><span>
</span><span id="line-1665"></span><span>        </span><span class="hs-comment">--</span><span>
</span><span id="line-1666"></span><span>        </span><span class="hs-comment">-- Note that to get reproducible builds, the variables need to be</span><span>
</span><span id="line-1667"></span><span>        </span><span class="hs-comment">-- abstracted in deterministic order, not dependent on the values of</span><span>
</span><span id="line-1668"></span><span>        </span><span class="hs-comment">-- Uniques. This is achieved by using DVarSets, deterministic free</span><span>
</span><span id="line-1669"></span><span>        </span><span class="hs-comment">-- variable computation and deterministic sort.</span><span>
</span><span id="line-1670"></span><span>        </span><span class="hs-comment">-- See Note [Unique Determinism] in GHC.Types.Unique for explanation of why</span><span>
</span><span id="line-1671"></span><span>        </span><span class="hs-comment">-- Uniques are not deterministic.</span><span>
</span><span id="line-1672"></span><span id="abstractVars"><span class="annot"><span class="annottext">abstractVars :: Level -&gt; LevelEnv -&gt; FVAnn -&gt; [Id]
</span><a href="GHC.Core.Opt.SetLevels.html#abstractVars"><span class="hs-identifier hs-var hs-var">abstractVars</span></a></span></span><span> </span><span id="local-6989586621680962275"><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962275"><span class="hs-identifier hs-var">dest_lvl</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LE"><span class="hs-identifier hs-type">LE</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">le_subst :: LevelEnv -&gt; Subst
</span><a href="GHC.Core.Opt.SetLevels.html#le_subst"><span class="hs-identifier hs-var">le_subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680962274"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680962274"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">le_lvl_env :: LevelEnv -&gt; VarEnv Level
</span><a href="GHC.Core.Opt.SetLevels.html#le_lvl_env"><span class="hs-identifier hs-var">le_lvl_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680962273"><span class="annot"><span class="annottext">VarEnv Level
</span><a href="#local-6989586621680962273"><span class="hs-identifier hs-var">lvl_env</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621680962272"><span class="annot"><span class="annottext">FVAnn
</span><a href="#local-6989586621680962272"><span class="hs-identifier hs-var">in_fvs</span></a></span></span><span>
</span><span id="line-1673"></span><span>  </span><span class="hs-glyph">=</span><span>  </span><span class="hs-comment">-- NB: sortQuantVars might not put duplicates next to each other</span><span>
</span><span id="line-1674"></span><span>    </span><span class="annot"><span class="annottext">(Id -&gt; Id) -&gt; [Id] -&gt; [Id]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Id
</span><a href="#local-6989586621680962271"><span class="hs-identifier hs-var">zap</span></a></span><span> </span><span class="annot"><span class="annottext">([Id] -&gt; [Id]) -&gt; [Id] -&gt; [Id]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [Id]
</span><a href="GHC.Core.Make.html#sortQuantVars"><span class="hs-identifier hs-var">sortQuantVars</span></a></span><span> </span><span class="annot"><span class="annottext">([Id] -&gt; [Id]) -&gt; [Id] -&gt; [Id]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1675"></span><span>    </span><span class="annot"><span class="annottext">(Id -&gt; Bool) -&gt; [Id] -&gt; [Id]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="#local-6989586621680962270"><span class="hs-identifier hs-var">abstract_me</span></a></span><span>      </span><span class="annot"><span class="annottext">([Id] -&gt; [Id]) -&gt; [Id] -&gt; [Id]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1676"></span><span>    </span><span class="annot"><span class="annottext">FVAnn -&gt; [Id]
</span><a href="GHC.Types.Var.Set.html#dVarSetElems"><span class="hs-identifier hs-var">dVarSetElems</span></a></span><span>            </span><span class="annot"><span class="annottext">(FVAnn -&gt; [Id]) -&gt; FVAnn -&gt; [Id]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1677"></span><span>    </span><span class="annot"><span class="annottext">FVAnn -&gt; FVAnn
</span><a href="GHC.Core.TyCo.FVs.html#closeOverKindsDSet"><span class="hs-identifier hs-var">closeOverKindsDSet</span></a></span><span>      </span><span class="annot"><span class="annottext">(FVAnn -&gt; FVAnn) -&gt; FVAnn -&gt; FVAnn
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1678"></span><span>    </span><span class="annot"><span class="annottext">Subst -&gt; FVAnn -&gt; FVAnn
</span><a href="GHC.Core.Subst.html#substDVarSet"><span class="hs-identifier hs-var">substDVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680962274"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">FVAnn
</span><a href="#local-6989586621680962272"><span class="hs-identifier hs-var">in_fvs</span></a></span><span>
</span><span id="line-1679"></span><span>        </span><span class="hs-comment">-- NB: it's important to call abstract_me only on the OutIds the</span><span>
</span><span id="line-1680"></span><span>        </span><span class="hs-comment">-- come from substDVarSet (not on fv, which is an InId)</span><span>
</span><span id="line-1681"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1682"></span><span>    </span><span id="local-6989586621680962270"><span class="annot"><span class="annottext">abstract_me :: Id -&gt; Bool
</span><a href="#local-6989586621680962270"><span class="hs-identifier hs-var hs-var">abstract_me</span></a></span></span><span> </span><span id="local-6989586621680962267"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962267"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">VarEnv Level -&gt; Id -&gt; Maybe Level
forall a. VarEnv a -&gt; Id -&gt; Maybe a
</span><a href="GHC.Types.Var.Env.html#lookupVarEnv"><span class="hs-identifier hs-var">lookupVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">VarEnv Level
</span><a href="#local-6989586621680962273"><span class="hs-identifier hs-var">lvl_env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962267"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1683"></span><span>                        </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680962266"><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962266"><span class="hs-identifier hs-var">lvl</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962275"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">Level -&gt; Level -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#ltLvl"><span class="hs-operator hs-var">`ltLvl`</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962266"><span class="hs-identifier hs-var">lvl</span></a></span><span>
</span><span id="line-1684"></span><span>                        </span><span class="annot"><span class="annottext">Maybe Level
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1685"></span><span>
</span><span id="line-1686"></span><span>        </span><span class="hs-comment">-- We are going to lambda-abstract, so nuke any IdInfo,</span><span>
</span><span id="line-1687"></span><span>        </span><span class="hs-comment">-- and add the tyvars of the Id (if necessary)</span><span>
</span><span id="line-1688"></span><span>    </span><span id="local-6989586621680962271"><span class="annot"><span class="annottext">zap :: Id -&gt; Id
</span><a href="#local-6989586621680962271"><span class="hs-identifier hs-var hs-var">zap</span></a></span></span><span> </span><span id="local-6989586621680962261"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962261"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isId"><span class="hs-identifier hs-var">isId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962261"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">WARN</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isStableUnfolding</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">idUnfolding</span><span> </span><span class="hs-identifier">v</span><span class="hs-special">)</span><span> </span><span class="hs-operator">||</span><span>
</span><span id="line-1689"></span><span>                           </span><span class="hs-identifier">not</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">isEmptyRuleInfo</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">idSpecialisation</span><span> </span><span class="hs-identifier">v</span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-1690"></span><span>                           </span><span class="hs-identifier">text</span><span> </span><span class="hs-string">&quot;absVarsOf: discarding info on&quot;</span><span> </span><span class="hs-operator">&lt;+&gt;</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">v</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-1691"></span><span>                     </span><span class="annot"><span class="annottext">Id -&gt; IdInfo -&gt; Id
</span><a href="GHC.Types.Id.html#setIdInfo"><span class="hs-identifier hs-var">setIdInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962261"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">IdInfo
</span><a href="GHC.Types.Id.Info.html#vanillaIdInfo"><span class="hs-identifier hs-var">vanillaIdInfo</span></a></span><span>
</span><span id="line-1692"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962261"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-1693"></span><span>
</span><span id="line-1694"></span><span class="hs-keyword">type</span><span> </span><span id="LvlM"><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LvlM"><span class="hs-identifier hs-var">LvlM</span></a></span></span><span> </span><span id="local-6989586621680962251"><span class="annot"><a href="#local-6989586621680962251"><span class="hs-identifier hs-type">result</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Supply.html#UniqSM"><span class="hs-identifier hs-type">UniqSM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680962251"><span class="hs-identifier hs-type">result</span></a></span><span>
</span><span id="line-1695"></span><span>
</span><span id="line-1696"></span><span id="local-6989586621680963306"><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#initLvl"><span class="hs-identifier hs-type">initLvl</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Supply.html#UniqSupply"><span class="hs-identifier hs-type">UniqSupply</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Supply.html#UniqSM"><span class="hs-identifier hs-type">UniqSM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680963306"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680963306"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-1697"></span><span id="initLvl"><span class="annot"><span class="annottext">initLvl :: forall a. UniqSupply -&gt; UniqSM a -&gt; a
</span><a href="GHC.Core.Opt.SetLevels.html#initLvl"><span class="hs-identifier hs-var hs-var">initLvl</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UniqSupply -&gt; UniqSM a -&gt; a
forall a. UniqSupply -&gt; UniqSM a -&gt; a
</span><a href="GHC.Types.Unique.Supply.html#initUs_"><span class="hs-identifier hs-var">initUs_</span></a></span><span>
</span><span id="line-1698"></span><span>
</span><span id="line-1699"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#newPolyBndrs"><span class="hs-identifier hs-type">newPolyBndrs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#OutVar"><span class="hs-identifier hs-type">OutVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#InId"><span class="hs-identifier hs-type">InId</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1700"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LvlM"><span class="hs-identifier hs-type">LvlM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1701"></span><span class="hs-comment">-- The envt is extended to bind the new bndrs to dest_lvl, but</span><span>
</span><span id="line-1702"></span><span class="hs-comment">-- the le_ctxt_lvl is unaffected</span><span>
</span><span id="line-1703"></span><span id="newPolyBndrs"><span class="annot"><span class="annottext">newPolyBndrs :: Level -&gt; LevelEnv -&gt; [Id] -&gt; [Id] -&gt; LvlM (LevelEnv, [Id])
</span><a href="GHC.Core.Opt.SetLevels.html#newPolyBndrs"><span class="hs-identifier hs-var hs-var">newPolyBndrs</span></a></span></span><span> </span><span id="local-6989586621680962247"><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962247"><span class="hs-identifier hs-var">dest_lvl</span></a></span></span><span>
</span><span id="line-1704"></span><span>             </span><span id="local-6989586621680962246"><span class="annot"><span class="annottext">env :: LevelEnv
</span><a href="#local-6989586621680962246"><span class="hs-identifier hs-var">env</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LE"><span class="hs-identifier hs-type">LE</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">le_lvl_env :: LevelEnv -&gt; VarEnv Level
</span><a href="GHC.Core.Opt.SetLevels.html#le_lvl_env"><span class="hs-identifier hs-var">le_lvl_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680962245"><span class="annot"><span class="annottext">VarEnv Level
</span><a href="#local-6989586621680962245"><span class="hs-identifier hs-var">lvl_env</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">le_subst :: LevelEnv -&gt; Subst
</span><a href="GHC.Core.Opt.SetLevels.html#le_subst"><span class="hs-identifier hs-var">le_subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680962244"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680962244"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">le_env :: LevelEnv -&gt; IdEnv ([Id], LevelledExpr)
</span><a href="GHC.Core.Opt.SetLevels.html#le_env"><span class="hs-identifier hs-var">le_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680962243"><span class="annot"><span class="annottext">IdEnv ([Id], LevelledExpr)
</span><a href="#local-6989586621680962243"><span class="hs-identifier hs-var">id_env</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1705"></span><span>             </span><span id="local-6989586621680962242"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962242"><span class="hs-identifier hs-var">abs_vars</span></a></span></span><span> </span><span id="local-6989586621680962241"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962241"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span>
</span><span id="line-1706"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">all</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">not</span><span> </span><span class="hs-operator">.</span><span> </span><span class="hs-identifier">isCoVar</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">bndrs</span><span> </span><span class="hs-special">)</span><span>   </span><span class="hs-comment">-- What would we add to the CoSubst in this case. No easy answer.</span><span>
</span><span id="line-1707"></span><span>   </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680962240"><span class="annot"><span class="annottext">[Unique]
</span><a href="#local-6989586621680962240"><span class="hs-identifier hs-var">uniqs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UniqSM [Unique]
forall (m :: * -&gt; *). MonadUnique m =&gt; m [Unique]
</span><a href="GHC.Types.Unique.Supply.html#getUniquesM"><span class="hs-identifier hs-var">getUniquesM</span></a></span><span>
</span><span id="line-1708"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680962238"><span class="annot"><span class="annottext">new_bndrs :: [Id]
</span><a href="#local-6989586621680962238"><span class="hs-identifier hs-var hs-var">new_bndrs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Unique -&gt; Id) -&gt; [Id] -&gt; [Unique] -&gt; [Id]
forall a b c. (a -&gt; b -&gt; c) -&gt; [a] -&gt; [b] -&gt; [c]
</span><a href="../../base/src/GHC.List.html#zipWith"><span class="hs-identifier hs-var">zipWith</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Unique -&gt; Id
</span><a href="#local-6989586621680962236"><span class="hs-identifier hs-var">mk_poly_bndr</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962241"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">[Unique]
</span><a href="#local-6989586621680962240"><span class="hs-identifier hs-var">uniqs</span></a></span><span>
</span><span id="line-1709"></span><span>            </span><span id="local-6989586621680962235"><span class="annot"><span class="annottext">bndr_prs :: [(Id, Id)]
</span><a href="#local-6989586621680962235"><span class="hs-identifier hs-var hs-var">bndr_prs</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962241"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [Id] -&gt; [(Id, Id)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-operator hs-var">`zip`</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962238"><span class="hs-identifier hs-var">new_bndrs</span></a></span><span>
</span><span id="line-1710"></span><span>            </span><span id="local-6989586621680962232"><span class="annot"><span class="annottext">env' :: LevelEnv
</span><a href="#local-6989586621680962232"><span class="hs-identifier hs-var hs-var">env'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962246"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">le_lvl_env :: VarEnv Level
</span><a href="GHC.Core.Opt.SetLevels.html#le_lvl_env"><span class="hs-identifier hs-var">le_lvl_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level -&gt; VarEnv Level -&gt; [Id] -&gt; VarEnv Level
</span><a href="GHC.Core.Opt.SetLevels.html#addLvls"><span class="hs-identifier hs-var">addLvls</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962247"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">VarEnv Level
</span><a href="#local-6989586621680962245"><span class="hs-identifier hs-var">lvl_env</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962238"><span class="hs-identifier hs-var">new_bndrs</span></a></span><span>
</span><span id="line-1711"></span><span>                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">le_subst :: Subst
</span><a href="GHC.Core.Opt.SetLevels.html#le_subst"><span class="hs-identifier hs-var">le_subst</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Subst -&gt; (Id, Id) -&gt; Subst) -&gt; Subst -&gt; [(Id, Id)] -&gt; Subst
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">Subst -&gt; (Id, Id) -&gt; Subst
</span><a href="#local-6989586621680962231"><span class="hs-identifier hs-var">add_subst</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680962244"><span class="hs-identifier hs-var">subst</span></a></span><span>   </span><span class="annot"><span class="annottext">[(Id, Id)]
</span><a href="#local-6989586621680962235"><span class="hs-identifier hs-var">bndr_prs</span></a></span><span>
</span><span id="line-1712"></span><span>                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">le_env :: IdEnv ([Id], LevelledExpr)
</span><a href="GHC.Core.Opt.SetLevels.html#le_env"><span class="hs-identifier hs-var">le_env</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(IdEnv ([Id], LevelledExpr)
 -&gt; (Id, Id) -&gt; IdEnv ([Id], LevelledExpr))
-&gt; IdEnv ([Id], LevelledExpr)
-&gt; [(Id, Id)]
-&gt; IdEnv ([Id], LevelledExpr)
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">IdEnv ([Id], LevelledExpr)
-&gt; (Id, Id) -&gt; IdEnv ([Id], LevelledExpr)
forall {b}.
VarEnv ([Id], Expr b) -&gt; (Id, Id) -&gt; VarEnv ([Id], Expr b)
</span><a href="#local-6989586621680962230"><span class="hs-identifier hs-var">add_id</span></a></span><span>    </span><span class="annot"><span class="annottext">IdEnv ([Id], LevelledExpr)
</span><a href="#local-6989586621680962243"><span class="hs-identifier hs-var">id_env</span></a></span><span>  </span><span class="annot"><span class="annottext">[(Id, Id)]
</span><a href="#local-6989586621680962235"><span class="hs-identifier hs-var">bndr_prs</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1713"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(LevelEnv, [Id]) -&gt; LvlM (LevelEnv, [Id])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962232"><span class="hs-identifier hs-var">env'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962238"><span class="hs-identifier hs-var">new_bndrs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1714"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1715"></span><span>    </span><span id="local-6989586621680962231"><span class="annot"><span class="annottext">add_subst :: Subst -&gt; (Id, Id) -&gt; Subst
</span><a href="#local-6989586621680962231"><span class="hs-identifier hs-var hs-var">add_subst</span></a></span></span><span> </span><span id="local-6989586621680962229"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680962229"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680962228"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962228"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962227"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962227"><span class="hs-identifier hs-var">v'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; Id -&gt; Expr Id -&gt; Subst
</span><a href="GHC.Core.Subst.html#extendIdSubst"><span class="hs-identifier hs-var">extendIdSubst</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680962229"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962228"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Expr Id -&gt; [Id] -&gt; Expr Id
forall b. Expr b -&gt; [Id] -&gt; Expr b
</span><a href="GHC.Core.html#mkVarApps"><span class="hs-identifier hs-var">mkVarApps</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Expr Id
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962227"><span class="hs-identifier hs-var">v'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962242"><span class="hs-identifier hs-var">abs_vars</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1716"></span><span>    </span><span id="local-6989586621680962230"><span class="annot"><span class="annottext">add_id :: VarEnv ([Id], Expr b) -&gt; (Id, Id) -&gt; VarEnv ([Id], Expr b)
</span><a href="#local-6989586621680962230"><span class="hs-identifier hs-var hs-var">add_id</span></a></span></span><span>    </span><span id="local-6989586621680962225"><span class="annot"><span class="annottext">VarEnv ([Id], Expr b)
</span><a href="#local-6989586621680962225"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680962224"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962224"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962223"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962223"><span class="hs-identifier hs-var">v'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarEnv ([Id], Expr b)
-&gt; Id -&gt; ([Id], Expr b) -&gt; VarEnv ([Id], Expr b)
forall a. VarEnv a -&gt; Id -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">VarEnv ([Id], Expr b)
</span><a href="#local-6989586621680962225"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962224"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962223"><span class="hs-identifier hs-var">v'</span></a></span><span class="annot"><span class="annottext">Id -&gt; [Id] -&gt; [Id]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962242"><span class="hs-identifier hs-var">abs_vars</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Expr b -&gt; [Id] -&gt; Expr b
forall b. Expr b -&gt; [Id] -&gt; Expr b
</span><a href="GHC.Core.html#mkVarApps"><span class="hs-identifier hs-var">mkVarApps</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Expr b
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962223"><span class="hs-identifier hs-var">v'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962242"><span class="hs-identifier hs-var">abs_vars</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1717"></span><span>
</span><span id="line-1718"></span><span>    </span><span id="local-6989586621680962236"><span class="annot"><span class="annottext">mk_poly_bndr :: Id -&gt; Unique -&gt; Id
</span><a href="#local-6989586621680962236"><span class="hs-identifier hs-var hs-var">mk_poly_bndr</span></a></span></span><span> </span><span id="local-6989586621680962222"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962222"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621680962221"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621680962221"><span class="hs-identifier hs-var">uniq</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; [Id] -&gt; Id -&gt; Id
</span><a href="GHC.Types.Id.html#transferPolyIdInfo"><span class="hs-identifier hs-var">transferPolyIdInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962222"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962242"><span class="hs-identifier hs-var">abs_vars</span></a></span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Id) -&gt; Id -&gt; Id
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-comment">-- Note [transferPolyIdInfo] in GHC.Types.Id</span><span>
</span><span id="line-1719"></span><span>                             </span><span class="annot"><span class="annottext">Id -&gt; Id -&gt; Id
</span><a href="#local-6989586621680962219"><span class="hs-identifier hs-var">transfer_join_info</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962222"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Id) -&gt; Id -&gt; Id
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1720"></span><span>                             </span><span class="annot"><span class="annottext">FastString -&gt; Unique -&gt; Type -&gt; Type -&gt; Id
</span><a href="GHC.Types.Id.html#mkSysLocal"><span class="hs-identifier hs-var">mkSysLocal</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; FastString
</span><a href="GHC.Data.FastString.html#mkFastString"><span class="hs-identifier hs-var">mkFastString</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680962216"><span class="hs-identifier hs-var">str</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621680962221"><span class="hs-identifier hs-var">uniq</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Types.Id.html#idMult"><span class="hs-identifier hs-var">idMult</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962222"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680962215"><span class="hs-identifier hs-var">poly_ty</span></a></span><span>
</span><span id="line-1721"></span><span>                           </span><span class="hs-keyword">where</span><span>
</span><span id="line-1722"></span><span>                             </span><span id="local-6989586621680962216"><span class="annot"><span class="annottext">str :: String
</span><a href="#local-6989586621680962216"><span class="hs-identifier hs-var hs-var">str</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;poly_&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">OccName -&gt; String
</span><a href="GHC.Types.Name.Occurrence.html#occNameString"><span class="hs-identifier hs-var">occNameString</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; OccName
forall a. NamedThing a =&gt; a -&gt; OccName
</span><a href="GHC.Types.Name.html#getOccName"><span class="hs-identifier hs-var">getOccName</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962222"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1723"></span><span>                             </span><span id="local-6989586621680962215"><span class="annot"><span class="annottext">poly_ty :: Type
</span><a href="#local-6989586621680962215"><span class="hs-identifier hs-var hs-var">poly_ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; Type -&gt; Type
</span><a href="GHC.Core.Utils.html#mkLamTypes"><span class="hs-identifier hs-var">mkLamTypes</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962242"><span class="hs-identifier hs-var">abs_vars</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst -&gt; Type -&gt; Type
</span><a href="GHC.Core.Subst.html#substTy"><span class="hs-identifier hs-var">GHC.Core.Subst.substTy</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680962244"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962222"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1724"></span><span>
</span><span id="line-1725"></span><span>    </span><span class="hs-comment">-- If we are floating a join point to top level, it stops being</span><span>
</span><span id="line-1726"></span><span>    </span><span class="hs-comment">-- a join point.  Otherwise it continues to be a join point,</span><span>
</span><span id="line-1727"></span><span>    </span><span class="hs-comment">-- but we may need to adjust its arity</span><span>
</span><span id="line-1728"></span><span>    </span><span id="local-6989586621680962212"><span class="annot"><span class="annottext">dest_is_top :: Bool
</span><a href="#local-6989586621680962212"><span class="hs-identifier hs-var hs-var">dest_is_top</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#isTopLvl"><span class="hs-identifier hs-var">isTopLvl</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962247"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span>
</span><span id="line-1729"></span><span>    </span><span id="local-6989586621680962219"><span class="annot"><span class="annottext">transfer_join_info :: Id -&gt; Id -&gt; Id
</span><a href="#local-6989586621680962219"><span class="hs-identifier hs-var hs-var">transfer_join_info</span></a></span></span><span> </span><span id="local-6989586621680962209"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962209"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621680962208"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962208"><span class="hs-identifier hs-var">new_bndr</span></a></span></span><span>
</span><span id="line-1730"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680962207"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962207"><span class="hs-identifier hs-var">join_arity</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Maybe Int
</span><a href="GHC.Types.Id.html#isJoinId_maybe"><span class="hs-identifier hs-var">isJoinId_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962209"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-1731"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962212"><span class="hs-identifier hs-var">dest_is_top</span></a></span><span>
</span><span id="line-1732"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962208"><span class="hs-identifier hs-var">new_bndr</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Int -&gt; Id
</span><a href="GHC.Types.Id.html#asJoinId"><span class="hs-operator hs-var">`asJoinId`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680962207"><span class="hs-identifier hs-var">join_arity</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962242"><span class="hs-identifier hs-var">abs_vars</span></a></span><span>
</span><span id="line-1733"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1734"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962208"><span class="hs-identifier hs-var">new_bndr</span></a></span><span>
</span><span id="line-1735"></span><span>
</span><span id="line-1736"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#newLvlVar"><span class="hs-identifier hs-type">newLvlVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelledExpr"><span class="hs-identifier hs-type">LevelledExpr</span></a></span><span>        </span><span class="hs-comment">-- The RHS of the new binding</span><span>
</span><span id="line-1737"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#JoinArity"><span class="hs-identifier hs-type">JoinArity</span></a></span><span>     </span><span class="hs-comment">-- Its join arity, if it is a join point</span><span>
</span><span id="line-1738"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>                </span><span class="hs-comment">-- True &lt;=&gt; the RHS looks like (makeStatic ...)</span><span>
</span><span id="line-1739"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LvlM"><span class="hs-identifier hs-type">LvlM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>
</span><span id="line-1740"></span><span id="newLvlVar"><span class="annot"><span class="annottext">newLvlVar :: LevelledExpr -&gt; Maybe Int -&gt; Bool -&gt; LvlM Id
</span><a href="GHC.Core.Opt.SetLevels.html#newLvlVar"><span class="hs-identifier hs-var hs-var">newLvlVar</span></a></span></span><span> </span><span id="local-6989586621680962204"><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962204"><span class="hs-identifier hs-var">lvld_rhs</span></a></span></span><span> </span><span id="local-6989586621680962203"><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621680962203"><span class="hs-identifier hs-var">join_arity_maybe</span></a></span></span><span> </span><span id="local-6989586621680962202"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962202"><span class="hs-identifier hs-var">is_mk_static</span></a></span></span><span>
</span><span id="line-1741"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680962201"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621680962201"><span class="hs-identifier hs-var">uniq</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UniqSM Unique
forall (m :: * -&gt; *). MonadUnique m =&gt; m Unique
</span><a href="GHC.Types.Unique.Supply.html#getUniqueM"><span class="hs-identifier hs-var">getUniqueM</span></a></span><span>
</span><span id="line-1742"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Id -&gt; LvlM Id
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Id
</span><a href="#local-6989586621680962199"><span class="hs-identifier hs-var">add_join_info</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Unique -&gt; Type -&gt; Id
</span><a href="#local-6989586621680962198"><span class="hs-identifier hs-var">mk_id</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621680962201"><span class="hs-identifier hs-var">uniq</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680962197"><span class="hs-identifier hs-var">rhs_ty</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1743"></span><span>       </span><span class="hs-special">}</span><span>
</span><span id="line-1744"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1745"></span><span>    </span><span id="local-6989586621680962199"><span class="annot"><span class="annottext">add_join_info :: Id -&gt; Id
</span><a href="#local-6989586621680962199"><span class="hs-identifier hs-var hs-var">add_join_info</span></a></span></span><span> </span><span id="local-6989586621680962196"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962196"><span class="hs-identifier hs-var">var</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962196"><span class="hs-identifier hs-var">var</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Maybe Int -&gt; Id
</span><a href="GHC.Types.Id.html#asJoinId_maybe"><span class="hs-operator hs-var">`asJoinId_maybe`</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621680962203"><span class="hs-identifier hs-var">join_arity_maybe</span></a></span><span>
</span><span id="line-1746"></span><span>    </span><span id="local-6989586621680962194"><span class="annot"><span class="annottext">de_tagged_rhs :: Expr Id
</span><a href="#local-6989586621680962194"><span class="hs-identifier hs-var hs-var">de_tagged_rhs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelledExpr -&gt; Expr Id
forall t. TaggedExpr t -&gt; Expr Id
</span><a href="GHC.Core.html#deTagExpr"><span class="hs-identifier hs-var">deTagExpr</span></a></span><span> </span><span class="annot"><span class="annottext">LevelledExpr
</span><a href="#local-6989586621680962204"><span class="hs-identifier hs-var">lvld_rhs</span></a></span><span>
</span><span id="line-1747"></span><span>    </span><span id="local-6989586621680962197"><span class="annot"><span class="annottext">rhs_ty :: Type
</span><a href="#local-6989586621680962197"><span class="hs-identifier hs-var hs-var">rhs_ty</span></a></span></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Expr Id -&gt; Type
</span><a href="GHC.Core.Utils.html#exprType"><span class="hs-identifier hs-var">exprType</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621680962194"><span class="hs-identifier hs-var">de_tagged_rhs</span></a></span><span>
</span><span id="line-1748"></span><span>
</span><span id="line-1749"></span><span>    </span><span id="local-6989586621680962198"><span class="annot"><span class="annottext">mk_id :: Unique -&gt; Type -&gt; Id
</span><a href="#local-6989586621680962198"><span class="hs-identifier hs-var hs-var">mk_id</span></a></span></span><span> </span><span id="local-6989586621680962193"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621680962193"><span class="hs-identifier hs-var">uniq</span></a></span></span><span> </span><span id="local-6989586621680962192"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680962192"><span class="hs-identifier hs-var">rhs_ty</span></a></span></span><span>
</span><span id="line-1750"></span><span>      </span><span class="hs-comment">-- See Note [Grand plan for static forms] in GHC.Iface.Tidy.StaticPtrTable.</span><span>
</span><span id="line-1751"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680962202"><span class="hs-identifier hs-var">is_mk_static</span></a></span><span>
</span><span id="line-1752"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Type -&gt; Id
</span><a href="GHC.Types.Id.html#mkExportedVanillaId"><span class="hs-identifier hs-var">mkExportedVanillaId</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Unique -&gt; FastString -&gt; Name
</span><a href="GHC.Types.Name.html#mkSystemVarName"><span class="hs-identifier hs-var">mkSystemVarName</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621680962193"><span class="hs-identifier hs-var">uniq</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; FastString
</span><a href="GHC.Data.FastString.html#mkFastString"><span class="hs-identifier hs-var">mkFastString</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;static_ptr&quot;</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1753"></span><span>                            </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680962192"><span class="hs-identifier hs-var">rhs_ty</span></a></span><span>
</span><span id="line-1754"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1755"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FastString -&gt; Unique -&gt; Type -&gt; Type -&gt; Id
</span><a href="GHC.Types.Id.html#mkSysLocal"><span class="hs-identifier hs-var">mkSysLocal</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; FastString
</span><a href="GHC.Data.FastString.html#mkFastString"><span class="hs-identifier hs-var">mkFastString</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;lvl&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621680962193"><span class="hs-identifier hs-var">uniq</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Core.Type.html#Many"><span class="hs-identifier hs-var">Many</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680962192"><span class="hs-identifier hs-var">rhs_ty</span></a></span><span>
</span><span id="line-1756"></span><span>
</span><span id="line-1757"></span><span class="hs-comment">-- | Clone the binders bound by a single-alternative case.</span><span>
</span><span id="line-1758"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#cloneCaseBndrs"><span class="hs-identifier hs-type">cloneCaseBndrs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LvlM"><span class="hs-identifier hs-type">LvlM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1759"></span><span id="cloneCaseBndrs"><span class="annot"><span class="annottext">cloneCaseBndrs :: LevelEnv -&gt; Level -&gt; [Id] -&gt; LvlM (LevelEnv, [Id])
</span><a href="GHC.Core.Opt.SetLevels.html#cloneCaseBndrs"><span class="hs-identifier hs-var hs-var">cloneCaseBndrs</span></a></span></span><span> </span><span id="local-6989586621680962190"><span class="annot"><span class="annottext">env :: LevelEnv
</span><a href="#local-6989586621680962190"><span class="hs-identifier hs-var">env</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LE"><span class="hs-identifier hs-type">LE</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">le_subst :: LevelEnv -&gt; Subst
</span><a href="GHC.Core.Opt.SetLevels.html#le_subst"><span class="hs-identifier hs-var">le_subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680962189"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680962189"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">le_lvl_env :: LevelEnv -&gt; VarEnv Level
</span><a href="GHC.Core.Opt.SetLevels.html#le_lvl_env"><span class="hs-identifier hs-var">le_lvl_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680962188"><span class="annot"><span class="annottext">VarEnv Level
</span><a href="#local-6989586621680962188"><span class="hs-identifier hs-var">lvl_env</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">le_env :: LevelEnv -&gt; IdEnv ([Id], LevelledExpr)
</span><a href="GHC.Core.Opt.SetLevels.html#le_env"><span class="hs-identifier hs-var">le_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680962187"><span class="annot"><span class="annottext">IdEnv ([Id], LevelledExpr)
</span><a href="#local-6989586621680962187"><span class="hs-identifier hs-var">id_env</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1760"></span><span>               </span><span id="local-6989586621680962186"><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962186"><span class="hs-identifier hs-var">new_lvl</span></a></span></span><span> </span><span id="local-6989586621680962185"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962185"><span class="hs-identifier hs-var">vs</span></a></span></span><span>
</span><span id="line-1761"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680962184"><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621680962184"><span class="hs-identifier hs-var">us</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UniqSM UniqSupply
forall (m :: * -&gt; *). MonadUnique m =&gt; m UniqSupply
</span><a href="GHC.Types.Unique.Supply.html#getUniqueSupplyM"><span class="hs-identifier hs-var">getUniqueSupplyM</span></a></span><span>
</span><span id="line-1762"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680962182"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680962182"><span class="hs-identifier hs-var">subst'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962181"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962181"><span class="hs-identifier hs-var">vs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; UniqSupply -&gt; [Id] -&gt; (Subst, [Id])
</span><a href="GHC.Core.Subst.html#cloneBndrs"><span class="hs-identifier hs-var">cloneBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680962189"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621680962184"><span class="hs-identifier hs-var">us</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962185"><span class="hs-identifier hs-var">vs</span></a></span><span>
</span><span id="line-1763"></span><span>             </span><span class="hs-comment">-- N.B. We are not moving the body of the case, merely its case</span><span>
</span><span id="line-1764"></span><span>             </span><span class="hs-comment">-- binders.  Consequently we should *not* set le_ctxt_lvl and</span><span>
</span><span id="line-1765"></span><span>             </span><span class="hs-comment">-- le_join_ceil.  See Note [Setting levels when floating</span><span>
</span><span id="line-1766"></span><span>             </span><span class="hs-comment">-- single-alternative cases].</span><span>
</span><span id="line-1767"></span><span>             </span><span id="local-6989586621680962178"><span class="annot"><span class="annottext">env' :: LevelEnv
</span><a href="#local-6989586621680962178"><span class="hs-identifier hs-var hs-var">env'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962190"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">le_lvl_env :: VarEnv Level
</span><a href="GHC.Core.Opt.SetLevels.html#le_lvl_env"><span class="hs-identifier hs-var">le_lvl_env</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level -&gt; VarEnv Level -&gt; [Id] -&gt; VarEnv Level
</span><a href="GHC.Core.Opt.SetLevels.html#addLvls"><span class="hs-identifier hs-var">addLvls</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962186"><span class="hs-identifier hs-var">new_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">VarEnv Level
</span><a href="#local-6989586621680962188"><span class="hs-identifier hs-var">lvl_env</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962181"><span class="hs-identifier hs-var">vs'</span></a></span><span>
</span><span id="line-1768"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">le_subst :: Subst
</span><a href="GHC.Core.Opt.SetLevels.html#le_subst"><span class="hs-identifier hs-var">le_subst</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680962182"><span class="hs-identifier hs-var">subst'</span></a></span><span>
</span><span id="line-1769"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">le_env :: IdEnv ([Id], LevelledExpr)
</span><a href="GHC.Core.Opt.SetLevels.html#le_env"><span class="hs-identifier hs-var">le_env</span></a></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(IdEnv ([Id], LevelledExpr)
 -&gt; (Id, Id) -&gt; IdEnv ([Id], LevelledExpr))
-&gt; IdEnv ([Id], LevelledExpr)
-&gt; [(Id, Id)]
-&gt; IdEnv ([Id], LevelledExpr)
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">IdEnv ([Id], LevelledExpr)
-&gt; (Id, Id) -&gt; IdEnv ([Id], LevelledExpr)
</span><a href="GHC.Core.Opt.SetLevels.html#add_id"><span class="hs-identifier hs-var">add_id</span></a></span><span> </span><span class="annot"><span class="annottext">IdEnv ([Id], LevelledExpr)
</span><a href="#local-6989586621680962187"><span class="hs-identifier hs-var">id_env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962185"><span class="hs-identifier hs-var">vs</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [Id] -&gt; [(Id, Id)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-operator hs-var">`zip`</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962181"><span class="hs-identifier hs-var">vs'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1770"></span><span>
</span><span id="line-1771"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(LevelEnv, [Id]) -&gt; LvlM (LevelEnv, [Id])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962178"><span class="hs-identifier hs-var">env'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962181"><span class="hs-identifier hs-var">vs'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1772"></span><span>
</span><span id="line-1773"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#cloneLetVars"><span class="hs-identifier hs-type">cloneLetVars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#RecFlag"><span class="hs-identifier hs-type">RecFlag</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#Level"><span class="hs-identifier hs-type">Level</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#InVar"><span class="hs-identifier hs-type">InVar</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1774"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LvlM"><span class="hs-identifier hs-type">LvlM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelEnv"><span class="hs-identifier hs-type">LevelEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#OutVar"><span class="hs-identifier hs-type">OutVar</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1775"></span><span class="hs-comment">-- See Note [Need for cloning during float-out]</span><span>
</span><span id="line-1776"></span><span class="hs-comment">-- Works for Ids bound by let(rec)</span><span>
</span><span id="line-1777"></span><span class="hs-comment">-- The dest_lvl is attributed to the binders in the new env,</span><span>
</span><span id="line-1778"></span><span class="hs-comment">-- but cloneVars doesn't affect the le_ctxt_lvl of the incoming env</span><span>
</span><span id="line-1779"></span><span id="cloneLetVars"><span class="annot"><span class="annottext">cloneLetVars :: RecFlag -&gt; LevelEnv -&gt; Level -&gt; [Id] -&gt; LvlM (LevelEnv, [Id])
</span><a href="GHC.Core.Opt.SetLevels.html#cloneLetVars"><span class="hs-identifier hs-var hs-var">cloneLetVars</span></a></span></span><span> </span><span id="local-6989586621680962177"><span class="annot"><span class="annottext">RecFlag
</span><a href="#local-6989586621680962177"><span class="hs-identifier hs-var">is_rec</span></a></span></span><span>
</span><span id="line-1780"></span><span>          </span><span id="local-6989586621680962176"><span class="annot"><span class="annottext">env :: LevelEnv
</span><a href="#local-6989586621680962176"><span class="hs-identifier hs-var">env</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LE"><span class="hs-identifier hs-type">LE</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">le_subst :: LevelEnv -&gt; Subst
</span><a href="GHC.Core.Opt.SetLevels.html#le_subst"><span class="hs-identifier hs-var">le_subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680962175"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680962175"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">le_lvl_env :: LevelEnv -&gt; VarEnv Level
</span><a href="GHC.Core.Opt.SetLevels.html#le_lvl_env"><span class="hs-identifier hs-var">le_lvl_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680962174"><span class="annot"><span class="annottext">VarEnv Level
</span><a href="#local-6989586621680962174"><span class="hs-identifier hs-var">lvl_env</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">le_env :: LevelEnv -&gt; IdEnv ([Id], LevelledExpr)
</span><a href="GHC.Core.Opt.SetLevels.html#le_env"><span class="hs-identifier hs-var">le_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680962173"><span class="annot"><span class="annottext">IdEnv ([Id], LevelledExpr)
</span><a href="#local-6989586621680962173"><span class="hs-identifier hs-var">id_env</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1781"></span><span>          </span><span id="local-6989586621680962172"><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962172"><span class="hs-identifier hs-var">dest_lvl</span></a></span></span><span> </span><span id="local-6989586621680962171"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962171"><span class="hs-identifier hs-var">vs</span></a></span></span><span>
</span><span id="line-1782"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680962170"><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621680962170"><span class="hs-identifier hs-var">us</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UniqSM UniqSupply
forall (m :: * -&gt; *). MonadUnique m =&gt; m UniqSupply
</span><a href="GHC.Types.Unique.Supply.html#getUniqueSupplyM"><span class="hs-identifier hs-var">getUniqueSupplyM</span></a></span><span>
</span><span id="line-1783"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680962169"><span class="annot"><span class="annottext">vs1 :: [Id]
</span><a href="#local-6989586621680962169"><span class="hs-identifier hs-var hs-var">vs1</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Id) -&gt; [Id] -&gt; [Id]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Id
</span><a href="#local-6989586621680962168"><span class="hs-identifier hs-var">zap</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962171"><span class="hs-identifier hs-var">vs</span></a></span><span>
</span><span id="line-1784"></span><span>                      </span><span class="hs-comment">-- See Note [Zapping the demand info]</span><span>
</span><span id="line-1785"></span><span>             </span><span class="hs-special">(</span><span id="local-6989586621680962167"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680962167"><span class="hs-identifier hs-var">subst'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962166"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962166"><span class="hs-identifier hs-var">vs2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="#local-6989586621680962177"><span class="hs-identifier hs-var">is_rec</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1786"></span><span>                               </span><span class="annot"><span class="annottext">RecFlag
</span><a href="GHC.Types.Basic.html#NonRecursive"><span class="hs-identifier hs-var">NonRecursive</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; UniqSupply -&gt; [Id] -&gt; (Subst, [Id])
</span><a href="GHC.Core.Subst.html#cloneBndrs"><span class="hs-identifier hs-var">cloneBndrs</span></a></span><span>      </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680962175"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621680962170"><span class="hs-identifier hs-var">us</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962169"><span class="hs-identifier hs-var">vs1</span></a></span><span>
</span><span id="line-1787"></span><span>                               </span><span class="annot"><span class="annottext">RecFlag
</span><a href="GHC.Types.Basic.html#Recursive"><span class="hs-identifier hs-var">Recursive</span></a></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; UniqSupply -&gt; [Id] -&gt; (Subst, [Id])
</span><a href="GHC.Core.Subst.html#cloneRecIdBndrs"><span class="hs-identifier hs-var">cloneRecIdBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680962175"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621680962170"><span class="hs-identifier hs-var">us</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962169"><span class="hs-identifier hs-var">vs1</span></a></span><span>
</span><span id="line-1788"></span><span>             </span><span id="local-6989586621680962164"><span class="annot"><span class="annottext">prs :: [(Id, Id)]
</span><a href="#local-6989586621680962164"><span class="hs-identifier hs-var hs-var">prs</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962171"><span class="hs-identifier hs-var">vs</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [Id] -&gt; [(Id, Id)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-operator hs-var">`zip`</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962166"><span class="hs-identifier hs-var">vs2</span></a></span><span>
</span><span id="line-1789"></span><span>             </span><span id="local-6989586621680962162"><span class="annot"><span class="annottext">env' :: LevelEnv
</span><a href="#local-6989586621680962162"><span class="hs-identifier hs-var hs-var">env'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962176"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">le_lvl_env :: VarEnv Level
</span><a href="GHC.Core.Opt.SetLevels.html#le_lvl_env"><span class="hs-identifier hs-var">le_lvl_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Level -&gt; VarEnv Level -&gt; [Id] -&gt; VarEnv Level
</span><a href="GHC.Core.Opt.SetLevels.html#addLvls"><span class="hs-identifier hs-var">addLvls</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962172"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">VarEnv Level
</span><a href="#local-6989586621680962174"><span class="hs-identifier hs-var">lvl_env</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962166"><span class="hs-identifier hs-var">vs2</span></a></span><span>
</span><span id="line-1790"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">le_subst :: Subst
</span><a href="GHC.Core.Opt.SetLevels.html#le_subst"><span class="hs-identifier hs-var">le_subst</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680962167"><span class="hs-identifier hs-var">subst'</span></a></span><span>
</span><span id="line-1791"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">le_env :: IdEnv ([Id], LevelledExpr)
</span><a href="GHC.Core.Opt.SetLevels.html#le_env"><span class="hs-identifier hs-var">le_env</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(IdEnv ([Id], LevelledExpr)
 -&gt; (Id, Id) -&gt; IdEnv ([Id], LevelledExpr))
-&gt; IdEnv ([Id], LevelledExpr)
-&gt; [(Id, Id)]
-&gt; IdEnv ([Id], LevelledExpr)
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">IdEnv ([Id], LevelledExpr)
-&gt; (Id, Id) -&gt; IdEnv ([Id], LevelledExpr)
</span><a href="GHC.Core.Opt.SetLevels.html#add_id"><span class="hs-identifier hs-var">add_id</span></a></span><span> </span><span class="annot"><span class="annottext">IdEnv ([Id], LevelledExpr)
</span><a href="#local-6989586621680962173"><span class="hs-identifier hs-var">id_env</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, Id)]
</span><a href="#local-6989586621680962164"><span class="hs-identifier hs-var">prs</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1792"></span><span>
</span><span id="line-1793"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(LevelEnv, [Id]) -&gt; LvlM (LevelEnv, [Id])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LevelEnv
</span><a href="#local-6989586621680962162"><span class="hs-identifier hs-var">env'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680962166"><span class="hs-identifier hs-var">vs2</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1794"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1795"></span><span>    </span><span class="annot"><a href="#local-6989586621680962168"><span class="hs-identifier hs-type">zap</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span>
</span><span id="line-1796"></span><span>    </span><span id="local-6989586621680962168"><span class="annot"><span class="annottext">zap :: Id -&gt; Id
</span><a href="#local-6989586621680962168"><span class="hs-identifier hs-var hs-var">zap</span></a></span></span><span> </span><span id="local-6989586621680962161"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962161"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isId"><span class="hs-identifier hs-var">isId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962161"><span class="hs-identifier hs-var">v</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Id
</span><a href="#local-6989586621680962160"><span class="hs-identifier hs-var">zap_join</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Id
</span><a href="GHC.Types.Id.html#zapIdDemandInfo"><span class="hs-identifier hs-var">zapIdDemandInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962161"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1797"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962161"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-1798"></span><span>
</span><span id="line-1799"></span><span>    </span><span id="local-6989586621680962160"><span class="annot"><span class="annottext">zap_join :: Id -&gt; Id
</span><a href="#local-6989586621680962160"><span class="hs-identifier hs-var hs-var">zap_join</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Level -&gt; Bool
</span><a href="GHC.Core.Opt.SetLevels.html#isTopLvl"><span class="hs-identifier hs-var">isTopLvl</span></a></span><span> </span><span class="annot"><span class="annottext">Level
</span><a href="#local-6989586621680962172"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Id
</span><a href="GHC.Types.Id.html#zapJoinId"><span class="hs-identifier hs-var">zapJoinId</span></a></span><span>
</span><span id="line-1800"></span><span>             </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Id
forall a. a -&gt; a
</span><a href="../../base/src/GHC.Base.html#id"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-1801"></span><span>
</span><span id="line-1802"></span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#add_id"><span class="hs-identifier hs-type">add_id</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#IdEnv"><span class="hs-identifier hs-type">IdEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelledExpr"><span class="hs-identifier hs-type">LevelledExpr</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#IdEnv"><span class="hs-identifier hs-type">IdEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.SetLevels.html#LevelledExpr"><span class="hs-identifier hs-type">LevelledExpr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1803"></span><span id="add_id"><span class="annot"><span class="annottext">add_id :: IdEnv ([Id], LevelledExpr)
-&gt; (Id, Id) -&gt; IdEnv ([Id], LevelledExpr)
</span><a href="GHC.Core.Opt.SetLevels.html#add_id"><span class="hs-identifier hs-var hs-var">add_id</span></a></span></span><span> </span><span id="local-6989586621680962156"><span class="annot"><span class="annottext">IdEnv ([Id], LevelledExpr)
</span><a href="#local-6989586621680962156"><span class="hs-identifier hs-var">id_env</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680962155"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962155"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680962154"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962154"><span class="hs-identifier hs-var">v1</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1804"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isTyVar"><span class="hs-identifier hs-var">isTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962155"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdEnv ([Id], LevelledExpr) -&gt; Id -&gt; IdEnv ([Id], LevelledExpr)
forall a. VarEnv a -&gt; Id -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#delVarEnv"><span class="hs-identifier hs-var">delVarEnv</span></a></span><span>    </span><span class="annot"><span class="annottext">IdEnv ([Id], LevelledExpr)
</span><a href="#local-6989586621680962156"><span class="hs-identifier hs-var">id_env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962155"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-1805"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdEnv ([Id], LevelledExpr)
-&gt; Id -&gt; ([Id], LevelledExpr) -&gt; IdEnv ([Id], LevelledExpr)
forall a. VarEnv a -&gt; Id -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">IdEnv ([Id], LevelledExpr)
</span><a href="#local-6989586621680962156"><span class="hs-identifier hs-var">id_env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962155"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680962154"><span class="hs-identifier hs-var">v1</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span class="hs-identifier">not</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">isCoVar</span><span> </span><span class="hs-identifier">v1</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">Var</span><span> </span><span class="hs-identifier">v1</span><span class="hs-special">)</span><span>
</span><span id="line-1806"></span><span>
</span><span id="line-1807"></span><span class="hs-comment">{-
Note [Zapping the demand info]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
VERY IMPORTANT: we must zap the demand info if the thing is going to
float out, because it may be less demanded than at its original
binding site.  Eg
   f :: Int -&gt; Int
   f x = let v = 3*4 in v+x
Here v is strict; but if we float v to top level, it isn't any more.

Similarly, if we're floating a join point, it won't be one anymore, so we zap
join point information as well.
-}</span><span>
</span><span id="line-1820"></span></pre></body></html>